saveBytesToFile method
Implementation
Future<dynamic> saveBytesToFile(Uint8List bytes, String fileName) async {
if (kIsWeb) {
// 🔹 WEB: Create a virtual file and trigger download
final blob = html.Blob([widget.file.bytes!]);
return html.Url.createObjectUrlFromBlob(blob);
} else {
// 🔹 MOBILE/DESKTOP: Save the file locally
final tempDir = await getTemporaryDirectory();
final file = File("${tempDir.path}/$fileName");
await file.writeAsBytes(bytes);
return file;
}
}