readBytes method

Uint8List readBytes()

Read Uint8List.

Implementation

Uint8List readBytes() {
  var length = buffer[_position++];
  bool add3 = !(length < 254);

  if (length < 254) {
    // NOP
  } else {
    length = readInt16() + (buffer[_position++] << 16);
  }

  final tmp = buffer.skip(_position).take(length).toList();
  _position += length;

  if (add3) {
    length += 3;
  }

  while (++length % 4 != 0) {
    _position++;
  }

  return Uint8List.fromList(tmp);
}