indexOutOfRange method

int indexOutOfRange(
  1. int input,
  2. Iterable values, {
  3. String? name,
})

Throws a RangeError if input is not a valid enum index. Returns input otherwise.

Implementation

int indexOutOfRange(int input, Iterable values, {String? name}) {
  if (values.length - 1 < input || input < 0) {
    throw RangeError.index(input, values);
  }
  return input;
}