DownloadTask class

Represents a single download task, including its metadata, status, and progress.

Constructors

DownloadTask.new({required Uri uri, int priority = 1, String? fileName, String cacheDir = "", double progress = 0.0, int downloadedBytes = 0, int totalBytes = 0, DownloadStatus status = DownloadStatus.IDLE, int startRange = 0, int? endRange, Map<String, Object>? headers, String? hlsKey})
Constructs a new DownloadTask with the given parameters. uri is required. fileName is optional; if not provided, uses the URI as the file name.

Properties

cacheDir String
The directory where the file will be cached.
getter/setter pair
createAt int
The timestamp (in milliseconds) when the task was created.
getter/setter pair
data List<int>
The list of data chunks downloaded (as bytes).
getter/setter pair
downloadedBytes int
The number of bytes downloaded so far.
getter/setter pair
endRange int?
The end byte range for partial download requests (nullable).
getter/setter pair
file File?
The file object where the downloaded data was saved, used to get the cache file entity which was downloaded in isolate.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, Object>?
The headers to be used for the download request (nullable).
getter/setter pair
hlsKey String?
The HLS key (generated from the URI) for the download, used to generate the cache directory, so that the segments of the same video can be cached in the same directory.
getter/setter pair
id String
Unique ID for the task, auto-incremented.
final
isolateSavePath String
The file path to be used in isolate operations.
getter/setter pair
matchUrl String
Generates a unique cache key for the download task, considering headers and range.
no setter
priority int
The priority of the task (default is 1, higher means higher priority).
getter/setter pair
progress double
The progress of the download, from 0.0 (not started) to 1.0 (completed).
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saveFile String
The name of the file to be saved.
getter/setter pair
saveFileName String
Returns the file name to be used for saving, including the extension.
no setter
startRange int
The start byte range for partial download requests.
getter/setter pair
status DownloadStatus
The current status of the download (e.g., IDLE, DOWNLOADING, PAUSED, COMPLETED, CANCELLED).
getter/setter pair
totalBytes int
The total number of bytes to be downloaded.
getter/setter pair
uri Uri
The URI of the file to be downloaded.
final
url String
Returns the URL string of the download target.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets the download progress and range information for the task.
toString() String
Returns a string representation of the download task, including all key properties.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

resetId() → void
Resets the static auto-incremented ID to 1.