DownloadTask constructor

DownloadTask({
  1. String? taskId,
  2. required String url,
  3. Map<String, String>? urlQueryParameters,
  4. String? filename,
  5. Map<String, String>? headers,
  6. String? httpRequestMethod,
  7. dynamic post,
  8. String directory = '',
  9. BaseDirectory baseDirectory = BaseDirectory.applicationDocuments,
  10. String group = 'default',
  11. Updates updates = Updates.status,
  12. bool requiresWiFi = false,
  13. int retries = 0,
  14. bool allowPause = false,
  15. int priority = 5,
  16. String metaData = '',
  17. String displayName = '',
  18. DateTime? creationTime,
})

Creates a DownloadTask

taskId must be unique. A unique id will be generated if omitted url properly encoded if necessary, can include query parameters urlQueryParameters may be added and will be appended to the url, must be properly encoded if necessary filename of the file to save. If omitted, a random filename will be generated headers an optional map of HTTP request headers httpRequestMethod the HTTP request method used (e.g. GET, POST) post if set, uses POST instead of GET. Post must be one of the following:

  • a String: POST request with post as the body, encoded in utf8
  • a Map: will be jsonEncoded to a String and set as the POST body
  • a List of bytes: will be converted to a String using String.fromCharCodes and set as the POST body
  • a List: map will be jsonEncoded to a String and set as the POST body

directory optional directory name, precedes filename baseDirectory one of the base directories, precedes directory group if set allows different callbacks or processing for different groups updates the kind of progress updates requested requiresWiFi if set, will not start download until WiFi is available. If not set may start download over cellular network retries if >0 will retry a failed download this many times allowPause if true, allows pause command priority in range 0 <= priority <= 10 with 0 highest, defaults to 5 metaData user data displayName human readable name for this task creationTime time of task creation, 'now' by default.

Implementation

DownloadTask(
    {super.taskId,
    required super.url,
    super.urlQueryParameters,
    super.filename,
    super.headers,
    super.httpRequestMethod,
    super.post,
    super.directory,
    super.baseDirectory,
    super.group,
    super.updates,
    super.requiresWiFi,
    super.retries,
    super.allowPause,
    super.priority,
    super.metaData,
    super.displayName,
    super.creationTime});