I stumbled upon this and hardly found anything but this worked for me as of the latest flutter version 2.5.0.
you have to add this script in the body of your web/index.html
file
<script src="https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.21.15/plugins/export/libs/FileSaver.js/FileSaver.min.js"></script>
and then just use this method to download any type of file
import 'dart:html' as html;
import 'dart:js' as js;
void save(Object bytes, String fileName) {
js.context.callMethod("saveAs", <Object>[
html.Blob(<Object>[bytes]),
fileName
]);
}
e.g I wanted to download a JSON response from the server so I called it like this.
save(json.encode(response.data), 'file.json');
With this method you can almost download any type of file, I did use this method to download images and JSON files and it is pretty straightforward.