saveTo method
Downloads a file by provided url
using save as
dialog.
onReceiveProgress
is only meaningful on non-Web platforms.
Implementation
Future<File?> saveTo(
String url, {
Function(int count, int total)? onReceiveProgress,
}) async {
String? to;
if (!isWeb) {
to = await FilePicker.platform.saveFile(
fileName: url.split('/').lastOrNull ?? 'file',
lockParentWindow: true,
);
if (to == null) {
return null;
}
}
return await download(
url,
url.split('/').lastOrNull ?? 'file',
null,
path: to,
onReceiveProgress: onReceiveProgress,
);
}