Task class sealed
Information related to a Task
A Task is the base class for DownloadTask and UploadTask
An equality test on a Task is a test on the taskId only - all other fields are ignored in that test
- Inheritance
- Implemented types
- Implementers
Constructors
-
Task({String? taskId, required String url, Map<
String, String> ? urlQueryParameters, String? filename, Map<String, String> ? headers, String? httpRequestMethod, dynamic post, String directory = '', BaseDirectory baseDirectory = BaseDirectory.applicationDocuments, String group = 'default', Updates updates = Updates.status, bool requiresWiFi = false, int retries = 0, String metaData = '', String displayName = '', bool allowPause = false, int priority = 5, DateTime? creationTime}) - Creates a Task
-
Task.createFromJson(Map<
String, dynamic> json) -
Create a new Task subclass from the provided
json
factory - Task.createFromJsonString(String jsonString)
-
Create a new Task subclass from provided
jsonString
factory -
Task.fromJson(Map<
String, dynamic> json) - Creates Task object from JsonMap
Properties
- allowPause → bool
-
If true, task will pause if the task fails partly through the execution,
when some but not all bytes have transferred, provided the server supports
partial transfers. Such failures are typically temporary, eg due to
connectivity issues, and may be resumed when connectivity returns.
If false, task fails on any issue, and task cannot be paused
final
- baseDirectory → BaseDirectory
-
Base directory
final
- creationTime → DateTime
-
Time at which this request was first created
finalinherited
- directory → String
-
Optional directory, relative to the base directory
final
- displayName → String
-
Human readable name for this task - use {displayName} in notification
final
- filename → String
-
Filename of the file to store - use {filename} in notification
final
- group → String
-
Group that this task belongs to
final
- hashCode → int
-
The hash code for this object.
no setteroverride
-
headers
→ Map<
String, String> -
potential additional headers to send with the request
finalinherited
- hostName → String
-
Hostname represented by the url. Throws FormatException if url cannot
be parsed, and returns empty string if no host in url
no setterinherited
- httpRequestMethod → String
-
HTTP request method to use
finalinherited
- metaData → String
-
User-defined metadata - use {metaData} in notification
final
- post → String?
-
Set post to make the request using POST instead of GET.
In the constructor, post must be one of the following:
finalinherited
- priority → int
-
Priority of this task, relative to other tasks.
Range 0 <= priority <= 10 with 0 being the highest priority.
Not all platforms will have the same actual granularity, and how
priority is considered is inconsistent across platforms.
final
- providesProgressUpdates → bool
-
If true, task expects progress updates
no setter
- providesStatusUpdates → bool
-
If true, task expects status updates
no setter
- requiresWiFi → bool
-
If true, will not download over cellular (metered) network
final
- retries → int
-
Maximum number of retries the downloader should attempt
finalinherited
- retriesRemaining ↔ int
-
Number of retries remaining
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- taskId → String
-
Identifier for the task - auto generated if omitted
final
- taskType → String
-
Returns the type of task as a String
no setter
- updates → Updates
-
Type of progress updates desired
final
- url → String
-
String representation of the url, urlEncoded
finalinherited
-
validHttpMethods
→ List<
String> -
finalinherited
Methods
-
compareTo(
dynamic other) → int -
Returns this.priority - other.priority if not the same
Returns this.creationTime - other.creationTime if priorities the same
Returns 0 if other is not a Task
override
-
copyWith(
{String? taskId, String? url, String? filename, Map< String, String> ? headers, String? httpRequestMethod, Object? post, String? directory, BaseDirectory? baseDirectory, String? group, Updates? updates, bool? requiresWiFi, int? retries, int? retriesRemaining, bool? allowPause, int? priority, String? metaData, String? displayName, DateTime? creationTime}) → Task - Returns a copy of the Task with optional changes to specific fields
-
decreaseRetriesRemaining(
) → void -
Decrease retriesRemaining by one
inherited
-
filePath(
{String? withFilename}) → Future< String> -
Returns the absolute path to the file represented by this task
based on the
Task.filename
(default) orwithFilename
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Creates JSON map of this object
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
- useExternalStorage ↔ bool
-
getter/setter pair
Static Methods
-
baseDirectoryPath(
BaseDirectory baseDirectory) → Future< String> -
Returns the path to the directory represented by
baseDirectory
-
split(
{String? filePath, File? file}) → Future< (BaseDirectory, String, String)> -
Extract the baseDirectory, directory and filename from
the provided
filePath
orfile
, and return this as a record