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
Response to bounty:
the case of an audio file it just starts playing rather than downloading it
I've done same thing with video, but I'm sure it will work with audio as well. I assume, your generated audio is an array or blob
import 'dart:js' as JS;
import 'dart:html' as HTML;
const mimeType = 'audio/wav'; // TODO: Pick a right format
void downloadFile(List chunks) async {
final blob = HTML.Blob(chunks, mimeType);
final objectUrl = await HTML.Url.createObjectUrlFromBlob(blob);
final a = HTML.AnchorElement();
a.href = item.url;
a.download = "my_audio_file_${DateTime.now()}.wav";
HTML.document.body.append(a);
a.click();
// Wait for click event to be processed and cleanup
await Future.delayed(Duration(milliseconds: 100));
a.remove();
HTML.Url.revokeObjectUrl(item.videoObjectUrl);
}