Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter WEB download option

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 which works for flutter web :(

Can someone please help me out?

like image 443
Pratik Avatar asked Jan 17 '20 08:01

Pratik


People also ask

How do I enable downloads in Flutter Webview?

It can recognize downloadable files in both Android (using setDownloadListener ) and iOS platforms! To be able to recognize downloadable files, you need to set the useOnDownloadStart: true option, and then you can listen the onDownloadStart event! Then, you need to ask permission using the permission_handler plugin.

How do you save on Flutter web?

Just call the method saveFile() with respective arguments.


1 Answers

Simple Code for redirecting to download URL

import 'dart:html' as html; void downloadFile(String url) {    html.AnchorElement anchorElement =  new html.AnchorElement(href: url);    anchorElement.download = url;    anchorElement.click(); } 
like image 62
vishwajit76 Avatar answered Oct 10 '22 02:10

vishwajit76