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 _pickSaveFile(options);
if (handle == null) return false;
final writable = await handle.createWritable().toDart;
try {
await for (final chunk in stream) {
final bytes = chunk is Uint8List ? chunk : Uint8List.fromList(chunk);
await writable.write(bytes.toJS).toDart;
}
await writable.close().toDart;
return true;
} catch (_) {
await _abort(writable);
rethrow;
}
}