readInt method

int readInt(
  1. int number, {
  2. Endianness endianness = Endianness.Big,
})

Implementation

int readInt(int number, {Endianness endianness = Endianness.Big}) {
  if (number > 8) {
    throw "Number of bytes converted to a int must be in [0,8), got $number";
  }
  Uint8List d = readBytes(number);
  int value = 0;
  if (endianness == Endianness.Big) {
    for (var n = 0; n < d.length; n++) {
      value <<= 8;
      value += d[n];
    }
  } else if (endianness == Endianness.Little) {
    for (var n = d.length - 1; n >= 0; n--) {
      value <<= 8;
      value += d[n];
    }
  }
  return value;
}