readBytes method

Future<Uint8List> readBytes({
  1. int? length,
  2. int offset = 0,
})

Reads at most length bytes from the file starting at offset. If length is null, reads until end of the file. Use read if you want to stream large file in chunks.

Implementation

Future<Uint8List> readBytes({int? length, int offset = 0}) async {
  final buffer = BytesBuilder(copy: false);
  await for (final chunk in read(length: length, offset: offset)) {
    buffer.add(chunk);
  }
  return buffer.takeBytes();
}