read method

Uint8List read(
  1. int length, [
  2. bool allocNew = true
])

Implementation

Uint8List read(int length, [bool allocNew = true]) {
  if (kIsWeb) {
    final bytes = Uint8List(length);
    for (int index = 0; index < length; index++) {
      bytes[index] = buffer.getUint8(readIndex++);
    }
    return bytes; // always new
  } else {
    final bytes = Uint8List.view(
        buffer.buffer, buffer.offsetInBytes + readIndex, length);
    readIndex += length;
    return allocNew ? Uint8List.fromList(bytes) : bytes;
  }
}