As I read Future cant be cancelled in flutter. I am downloading multiple files and showing the progress with LinearProgressIndicator. When user press back button and then come to loading screen again LinearProgressIndicator dows not work but from background Future feature keeps loading files.
I want the downloads to stop when user navigates away or I want them to keep visiting the page to check on progress.
Should I use singleton class to track progress value or can you suggest me better way?
Future<void> _initialize() async {
progressWait(await service.getWaitList(_listCourseWords),
(completed, total) {
setState(() {
_progressValue = completed / total;
});
if (completed == total) {
if (mounted)
setState(() {
isFilesDownloaded = true;
});
}
});
}