saveStream static method
Implementation
static Future<bool> saveStream({
required String name,
required Stream<List<int>> stream,
}) async {
if (!canSaveStream) {
throw UnsupportedError(
'Streamed web saving requires the File System Access API. '
'Use Chrome/Edge or use downloadLink for direct URL downloads.',
);
}
final options = JSObject();
options.setProperty('suggestedName'.toJS, name.toJS);
final handle = await _showSaveFilePicker(options).toDart;
final writable = await handle.createWritable().toDart;
try {
await for (final chunk in stream) {
await writable.write(Uint8List.fromList(chunk).toJS).toDart;
}
await writable.close().toDart;
return true;
} catch (_) {
await writable.abort().toDart;
rethrow;
}
}