readUint16 method Null safety

  1. @override
int readUint16()
override

Read a 16-bit word from the stream.

Implementation

@override
int readUint16() {
  var b1 = 0;
  var b2 = 0;
  if ((_bufferPosition + 2) < _bufferSize) {
    b1 = _buffer[_bufferPosition++] & 0xff;
    b2 = _buffer[_bufferPosition++] & 0xff;
  } else {
    b1 = readByte();
    b2 = readByte();
  }
  if (byteOrder == BIG_ENDIAN) {
    return (b1 << 8) | b2;
  }
  return (b2 << 8) | b1;
}