download method
Downloads a file from the provided url
.
Implementation
Downloading download(
String url,
String filename,
int? size, {
String? checksum,
String? to,
}) {
Downloading? downloading = downloads[checksum]?..start(url, to: to);
if (downloading == null) {
downloading = Downloading(
checksum,
filename,
size,
onDownloaded: (file) {
if (checksum != null) {
_downloadLocal?.upsert(checksum, file.path);
}
},
)..start(url, to: to);
if (checksum != null) {
downloads[checksum] = downloading;
}
}
return downloading;
}