cyberhybridhub/lib/utils/file_saver_web.dart
2026-06-07 03:10:21 +00:00

15 lines
470 B
Dart

import 'dart:html' as html;
import 'dart:typed_data';
Future<void> saveFileBytes(Uint8List bytes, String fileName) async {
final blob = html.Blob([bytes], 'text/plain; charset=utf-8');
final url = html.Url.createObjectUrlFromBlob(blob);
final anchor = html.AnchorElement(href: url)
..setAttribute("download", fileName)
..style.display = "none";
html.document.body?.append(anchor);
anchor.click();
anchor.remove();
html.Url.revokeObjectUrl(url);
}