readInt32 method

int readInt32([
  1. Endian endian = .big
])

Reads a 32-bit signed integer (-2,147,483,648 to 2,147,483,647).

endian specifies byte order (defaults to big-endian).

Example:

final coordinate = reader.readInt32();  // GPS coordinate

Throws RangeError if insufficient bytes are available.

Implementation

@pragma('vm:prefer-inline')
@pragma('dart2js:tryInline')
int readInt32([Endian endian = .big]) {
  _checkBounds(4, 'Int32');

  final value = _rs.data.getInt32(_rs.offset, endian);
  _rs.offset += 4;

  return value;
}