Files
filament_verwaltung/lib/helpers/web_download_helper.dart
2026-01-16 15:24:37 +01:00

16 lines
423 B
Dart

import 'dart:convert';
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
void downloadJsonFileWeb(String jsonData, String fileName) {
final bytes = utf8.encode(jsonData);
final blob = html.Blob([bytes]);
final url = html.Url.createObjectUrlFromBlob(blob);
final anchor = html.AnchorElement(href: url)
..setAttribute('download', fileName)
..click();
html.Url.revokeObjectUrl(url);
}