encodeInt method

void encodeInt(
  1. int position,
  2. int value,
  3. int numOfBytes,
  4. Endian endianness,
  5. bool signed,
)

Implementation

void encodeInt(
    int position, int value, int numOfBytes, Endian endianness, bool signed) {
  switch (numOfBytes) {
    case 4:
      byteArray.setInt32(position, value, endianness);
      break;
    case 2:
      byteArray.setInt16(position, value, endianness);
      break;
    case 1:
      byteArray.setInt8(position, value);
      break;
    default:
      throw Exception('Unsupported num of bytes: $numOfBytes');
  }
}