read method

Uint8List read(
  1. int count, {
  2. int? offset,
})

Read up to count bytes starting at position (or offset if given). Returns a fresh copy. Advances the cursor by the number of bytes returned.

Implementation

Uint8List read(int count, {int? offset}) {
  final b = _backing();
  final from = offset ?? _offset;
  if (from < 0 || from > b.length) {
    throw RangeError.range(from, 0, b.length, 'offset');
  }
  final end = math.min(from + count, b.length);
  final out = Uint8List.fromList(b.sublist(from, end));
  _offset = end;
  return out;
}