charAt method

  1. @override
int charAt(
  1. int index
)
override

Returns the byte value at the specified index. An index ranges from zero to length - 1. The first byte value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

@param index the index of the byte value to be returned

@return the specified byte value as character or the FNC1 character

@throws IndexOutOfBoundsException if the index argument is negative or not less than length @throws IllegalArgumentException if the value at the index argument is an ECI (isECI)

Implementation

@override
int charAt(int index) {
  if (index < 0 || index >= length) {
    //IndexOutOfBoundsException
    throw IndexError.withLength(index, length);
  }
  if (isECI(index)) {
    //IllegalArgumentException
    throw ArgumentError(
      'value at $index (${bytes[index]}) is not a character but an ECI',
    );
  }
  return isFNC1(index) ? fnc1 : bytes[index];
}