writeFileStream method

  1. @override
Future<void> writeFileStream(
  1. String filePath,
  2. Stream<Uint8List> dataStream
)
override

Writes a stream of bytes to a file at the given path Creates the file if it doesn't exist, overwrites if it does

Implementation

@override
Future<void> writeFileStream(
    String filePath, Stream<Uint8List> dataStream) async {
  final file = File(filePath);
  await file.create(recursive: true);
  final sink = file.openWrite();

  await for (final chunk in dataStream) {
    sink.add(chunk);
  }

  await sink.flush();
  await sink.close();
}