saveToBrowser method

Future<void> saveToBrowser()

Triggers a browser file download saving the file to the user's local Downloads folder on Web.

Throws UnsupportedError if called on non-web platforms.

Implementation

Future<void> saveToBrowser() async {
  if (!kIsWeb) {
    throw UnsupportedError('saveToBrowser() is only supported on web platforms.');
  }
  final rawBytes = await readAsBytes();
  await io_helper.downloadFileToBrowser(rawBytes, name, mimeType: mimeType);
}