readBytes method

Uint8List readBytes(
  1. int position,
  2. int count,
  3. int fileSize
)

Implementation

Uint8List readBytes(int position, int count, int fileSize) {
  if (count > _buffer.length) {
    if (position + count >= _fileSize) {
      count = _fileSize - position;
    }
    final bytes = Uint8List(count);
    _file.position = position;
    _file.readInto(bytes);
    return bytes;
  }

  if (position < _position ||
      (position + count) >= (_position + _bufferSize)) {
    _readBuffer(position, fileSize);
  }

  final start = position - _position;
  final bytes = _buffer.sublist(start, start + count);
  return bytes;
}