getIntAt method

int getIntAt(
  1. int offset,
  2. int bytes,
  3. StructEndian endian
)

Read integer with specified endianness

  • offset: The offset to read from
  • bytes: The number of bytes to read
  • endian: The endianness to use Returns the integer value read

Implementation

int getIntAt(int offset, int bytes, StructEndian endian) {
  switch (bytes) {
    case 1:
      return getInt8(offset);
    case 2:
      return getInt16(offset, endian.toEndian());
    case 4:
      return getInt32(offset, endian.toEndian());
    case 8:
      return getInt64(offset, endian.toEndian());
    default:
      throw ArgumentError('Unsupported integer size: $bytes bytes');
  }
}