Closed akshaybabloo closed 4 months ago
The saveFile() method on the web can just download file. This is what I have under my stub
saveFile()
import 'dart:js_interop'; import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; import 'package:web/web.dart'; void saveFile({ String? dialogTitle, String? fileName, String? initialDirectory, FileType type = FileType.any, List<String>? allowedExtensions, Uint8List? bytes, bool lockParentWindow = false, }) async { final data = bytes!.toJS; final blob = Blob([data].toJS, BlobPropertyBag(type: 'application/json')); final url = URL.createObjectURL(blob); final anchor = HTMLAnchorElement() ..href = url ..setAttribute("download", fileName ?? 'file') ..click(); URL.revokeObjectURL(url); }
Note: I have hardcoded application/json because I only need the JSON.
application/json
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
The
saveFile()
method on the web can just download file. This is what I have under my stub