DownloadTask constructor
DownloadTask({})
Constructs a new DownloadTask with the given parameters.
uri
is required. fileName
is optional; if not provided, uses the URI as the file name.
Implementation
DownloadTask({
required this.uri,
this.priority = 1,
String? fileName,
this.cacheDir = "",
this.progress = 0.0,
this.downloadedBytes = 0,
this.totalBytes = 0,
this.status = DownloadStatus.IDLE,
this.startRange = 0,
this.endRange,
this.headers,
this.hlsKey,
}) : id = _autoId.toString(),
saveFile = fileName ?? uri.toString() {
_autoId++;
// if (headers?.containsKey("range") == true) {
// String rangeStr = headers!["range"].toString();
// RegExp exp = RegExp(r'bytes=(\d+)-(\d*)');
// RegExpMatch? rangeMatch = exp.firstMatch(rangeStr);
// startRange = int.tryParse(rangeMatch?.group(1) ?? '0') ?? 0;
// endRange = int.tryParse(rangeMatch?.group(2) ?? '0') ?? -1;
// }
}