TRON -> TRON_MAINNET
This commit is contained in:
25
frontend/pweb/lib/utils/download.dart
Normal file
25
frontend/pweb/lib/utils/download.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:pshared/models/file/downloaded_file.dart';
|
||||
|
||||
|
||||
Future<void> downloadFile(DownloadedFile file) async {
|
||||
final blob = html.Blob(
|
||||
[Uint8List.fromList(file.bytes)],
|
||||
file.mimeType,
|
||||
);
|
||||
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
|
||||
final anchor = html.AnchorElement(href: url)
|
||||
..download = file.filename
|
||||
..style.display = 'none';
|
||||
|
||||
html.document.body!.append(anchor);
|
||||
anchor.click();
|
||||
anchor.remove();
|
||||
|
||||
html.Url.revokeObjectUrl(url);
|
||||
}
|
||||
Reference in New Issue
Block a user