DownloadTask constructor

DownloadTask({
  1. required Uri uri,
  2. int priority = 1,
  3. String? fileName,
  4. String cacheDir = "",
  5. double progress = 0.0,
  6. int downloadedBytes = 0,
  7. int totalBytes = 0,
  8. DownloadStatus status = DownloadStatus.IDLE,
  9. int startRange = 0,
  10. int? endRange,
  11. Map<String, Object>? headers,
  12. 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.

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;
  // }
}