Added class clearance fixes and improvements
Some checks failed
Release / meta (push) Successful in 18s
Release / android-build (push) Successful in 11m48s
Release / linux-build (push) Successful in 1m24s
Release / web-build (push) Successful in 6m15s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Some checks failed
Release / meta (push) Successful in 18s
Release / android-build (push) Successful in 11m48s
Release / linux-build (push) Successful in 1m24s
Release / web-build (push) Successful in 6m15s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
This commit is contained in:
29
lib/utils/download_helper.dart
Normal file
29
lib/utils/download_helper.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
|
||||
class SaveResult {
|
||||
final String? path;
|
||||
final bool canceled;
|
||||
|
||||
const SaveResult({this.path, required this.canceled});
|
||||
}
|
||||
|
||||
Future<SaveResult> saveBytes(
|
||||
Uint8List bytes,
|
||||
String filename, {
|
||||
String? mimeType,
|
||||
}) async {
|
||||
final safeName = filename.trim().isEmpty ? 'export.bin' : filename.trim();
|
||||
final location = await getSaveLocation(suggestedName: safeName);
|
||||
if (location == null) {
|
||||
return const SaveResult(canceled: true);
|
||||
}
|
||||
final file = XFile.fromData(
|
||||
bytes,
|
||||
mimeType: mimeType ?? 'application/octet-stream',
|
||||
name: safeName,
|
||||
);
|
||||
await file.saveTo(location.path);
|
||||
return SaveResult(path: location.path, canceled: false);
|
||||
}
|
||||
Reference in New Issue
Block a user