readRange method

  1. @override
Future<Uint8List> readRange(
  1. int offset,
  2. int length
)
override

Reads up to length bytes starting at offset. Best-effort at the end of the source: returns fewer bytes (down to empty) rather than padding or throwing. The reader checks the length it gets back itself, and reports a truncated file as an SvsFormatException.

Implementation

@override
Future<Uint8List> readRange(int offset, int length) async {
  final size = this.length;
  if (offset < 0 || length <= 0 || offset >= size) return Uint8List(0);
  final end = offset + length > size ? size : offset + length;
  final buffer = await _blob.slice(offset, end).arrayBuffer().toDart;
  return buffer.toDart.asUint8List();
}