download static method
Static method to fire file downloading returns future of DownloadTask which may be used to control the request
headersare custom HTTP headers for client, may be used for request authentication- if
clientisnullthe default one will be used fileis download path, file will be created while downloadingdeleteOnCancelspecify if file should be deleted after download is cancelleddeleteOnErrorspecify if file should be deleted when error is raisedsizeused to specify bytes end for range headersafeRangeused to skip range header if bytes end not found
Implementation
static Future<DownloadTask> download(
Uri url, {
Map<String, String> headers = const {},
http.Client? client,
required File file,
bool deleteOnCancel = true,
bool deleteOnError = false,
int? size,
bool safeRange = false,
}) async {
final task = DownloadTask._(
url: url,
headers: headers,
client: client ?? http.Client(),
file: file,
deleteOnCancel: deleteOnCancel,
deleteOnError: deleteOnError,
size: size,
safeRange: safeRange);
await task.resume();
return task;
}