feat: support browse files on web (#283)

This commit is contained in:
Levi authored and GitHub committed 2023-11-29 18:24:01 +08:00
1 parent ee7da179c1
commit db15650664
14 files changed
+145 -71

No files matched your search

@@ -0,0 +1,4 @@
import 'browser_download_stub.dart'
if (dart.library.html) 'entry/browser_download_browser.dart';
void download(String url, String name) => doDownload(url, name);
@@ -0,0 +1 @@
void doDownload(String url, String name) => throw UnimplementedError();
@@ -0,0 +1,9 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
void doDownload(String url, String name) {
final anchorElement = html.AnchorElement(href: url);
anchorElement.download = name;
anchorElement.target = '_blank';
anchorElement.click();
}