DownloadTask class

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

Constructors

DownloadTask({required Uri uri, int priority = 1, String? fileName, String cacheDir = "", double progress = 0.0, int cachedBytes = 0, int downloadedBytes = 0, int totalBytes = 0, DownloadStatus status = DownloadStatus.IDLE, int startRange = 0, int? endRange, Map<String, Object>? headers, String? hlsKey, int retryTimes = 0, CancelToken? cancelToken})
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

cachedBytes int
The number of bytes cached so far.
getter/setter pair
cacheDir String
The directory where the file will be cached.
getter/setter pair
cancelToken CancelToken?
The CancelToken used to cancel the download request (nullable).
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
fileName String
The name of the file to be saved.
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
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
retryTimes int
The number of retry attempts for the download task.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saveFileName String
Returns the file name to be used for saving, including the extension.
no setter
savePath String
Returns the file path to be used for saving.
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.