readUint32 method Null safety

  1. @override
int readUint32()
override

Read a 32-bit word from the stream.

Implementation

@override
int readUint32() {
  var b1 = 0;
  var b2 = 0;
  var b3 = 0;
  var b4 = 0;
  if ((_bufferPosition + 4) < _bufferSize) {
    b1 = _buffer[_bufferPosition++] & 0xff;
    b2 = _buffer[_bufferPosition++] & 0xff;
    b3 = _buffer[_bufferPosition++] & 0xff;
    b4 = _buffer[_bufferPosition++] & 0xff;
  } else {
    b1 = readByte();
    b2 = readByte();
    b3 = readByte();
    b4 = readByte();
  }

  if (byteOrder == BIG_ENDIAN) {
    return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
  }
  return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;
}