how to check when all the download are finished
Hello, how can i check when all the download are finished with flutter_downloader package? I have many downloads and i would like check when all the download are finished and not one by one.
Thank you
You can achieve what you want like this (sample taken from README and modified):
ReceivePort _port = ReceivePort();
@override
void initState() {
super.initState();
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
_getAllDownloadTasks();
setState((){ });
});
FlutterDownloader.registerCallback(downloadCallback); // see README for this
}
Future<void> _getAllDownloadTasks() async {
final allDownloadTasks = await FlutterDownloader.loadTasks();
var allCompleted = true;
for (final downloadTask in allDownloadTasks) {
if (downloadTask.status == DownloadTaskStatus.complete) {
print('this task is finished');
} else {
allCompleted = false;
}
if (allCompleted) {
print('all downloads are complete');
}
}
Does it solve your problem @amedeopro? If yes, feel free to close the issue :)
Thank you very much, I'll try and let you know, do you know if anyone is updating the package for windows compatibility? @bartekpacia
@amedeopro I'm pretty sure nobody is working on this, unfortunately.
You can subscribe to issue #617 to be up to date. Maybe someone will start working on it in the future.