start method
Starts the downloading.
Implementation
Future<void> start() async {
if (_cancelToken != null) {
return;
}
_cancelToken = CancelToken();
progress.value = 0;
try {
file.value = await PlatformUtils.download(
url,
url.split('/').lastOrNull ?? 'file',
null,
onReceiveProgress: (a, b) {
if (b != 0) {
progress.value = a / b;
}
},
cancelToken: _cancelToken,
);
if (file.value != null) {
progress.value = 1;
MessagePopup.success('label_file_downloaded'.l10n);
}
} finally {
progress.value = 0;
}
}