I am making flutter web app that should generate a file from user data. And have the option to download the output file.
But I can not find any options/packages whic
One way to trigger download is the adapt a common pattern used in "native" javascript, create an anchor element with the download
attribute and trigger a click.
import 'dart:convert';
import 'dart:html';
main() {
File file = // generated somewhere
final rawData = file.readAsBytesSync();
final content = base64Encode(rawData);
final anchor = AnchorElement(
href: "data:application/octet-stream;charset=utf-16le;base64,$content")
..setAttribute("download", "file.txt")
..click();
}