download static method
Static method to fire file downloading returns future of DownloadTask which may be used to control the request
headers
are custom HTTP headers for client, may be used for request authentication- if
client
isnull
the default one will be used file
is download path, file will be created while downloadingdeleteOnCancel
specify if file should be deleted after download is cancelleddeleteOnError
specify if file should be deleted when error is raisedsize
used to specify bytes end for range headersafeRange
used 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;
}