createAndDownload method
Forms and downloads the provided bytes
as a file.
Implementation
Future<File?> createAndDownload(String name, Uint8List bytes) async {
if (isWeb) {
await WebUtils.downloadBlob(name, bytes);
return null;
}
String? to;
if (PlatformUtils.isDesktop) {
to = await FilePicker.platform.saveFile(
fileName: name,
lockParentWindow: true,
);
} else {
to = (await temporaryDirectory).path;
}
if (to != null) {
final File file = File(to);
await file.writeAsBytes(bytes);
return file;
}
return null;
}