2017-05-20 47 views

回答

1

此問題已經是asked and answered for JS。非常類似的解決方案適用於Dart,只需很少的修改。例如,我們可以使用自定義數據URI,要麼目前它的用戶創建了一個錨元素或致電click方法:

String encodedFileContents = Uri.encodeComponent("Hello World!"); 

new AnchorElement(href: "data:text/plain;charset=utf-8,$encodedFileContents") 
    ..setAttribute("download", "file.txt") 
    ..click(); 

DartPad example,允許用戶編輯表格元素的單元格,然後下載細胞內容作爲csv文件。