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 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); }