read method

  1. @override
Future<Uint8List> read(
  1. int offset,
  2. int count
)
override

Reads exactly count bytes at offset; throws RangeError past the end.

Implementation

@override
Future<Uint8List> read(int offset, int count) {
  RangeError.checkValidRange(offset, offset + count, length);
  // RandomAccessFile allows one pending operation at a time → serialise.
  final done = _lock.then((_) async {
    await _raf.setPosition(offset);
    final b = await _raf.read(count);
    if (b.length != count) throw RangeError('short read at $offset');
    return b;
  });
  _lock = done.then((_) {}, onError: (Object _) {});
  return done;
}