You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
meshcore-client/lib/utils/log_web_download_web.dart

19 lines
602 B

import 'dart:js_interop';
import 'package:web/web.dart' as web;
/// Trigger a browser download of [content] (UTF-8 text) as [fileName] by
/// creating an in-memory Blob and clicking a transient anchor. #433
void downloadTextFile(String fileName, String content) {
final blob = web.Blob(
<JSAny>[content.toJS].toJS,
web.BlobPropertyBag(type: 'text/plain;charset=utf-8'),
);
final url = web.URL.createObjectURL(blob);
final anchor = web.document.createElement('a') as web.HTMLAnchorElement
..href = url
..download = fileName;
anchor.click();
web.URL.revokeObjectURL(url);
}

Powered by TurnKey Linux.