readBytes method Null safety

List<int> readBytes(
  1. int count
)

Read count bytes from the buffer.

Implementation

List<int> readBytes(int count) {
  if (buffer is Uint8List) {
    final b = buffer as Uint8List;
    final bytes = Uint8List.view(b.buffer, b.offsetInBytes + offset, count);
    offset += bytes.length;
    return bytes;
  }

  final bytes = buffer.sublist(offset, offset + count);
  offset += bytes.length;
  return bytes;
}