I am developing a web app with Flutter (web) and I need to download a file (of any type of extension) via a URL, DOWNLOAD it and not open it through the browser. The problem is that using this code, it does download the file but it seems to be corrupted.
String downloadFile(String filename) {
String? url= 'https://www.xxxxxx.it/yyyy/zzzz'+'/'+filename;
var ciao = html.Url.createObjectUrlFromBlob(html.Blob([url]));
html.AnchorElement(href: ciao)
..setAttribute('download', filename)
..click();
return "File "+filename+" in download!";
}