checkListIndex function

int checkListIndex (int index, int size, { dynamic message })

Throws a RangeError if the given index is not a valid index for a list with size elements. Otherwise, returns the index parameter.


int checkListIndex(int index, int size, {message}) {
  if (index < 0 || index >= size) {
    throw new RangeError(_resolveMessage(
        message, 'index $index not valid for list of size $size'));
  return index;