elementAtOrElse method

T elementAtOrElse(
  1. int index,
  2. T defaultValue(
    1. int index
    )
)

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this list.

Implementation

T elementAtOrElse(int index, T Function(int index) defaultValue) {
  return index >= 0 && index <= lastIndex ? get(index) : defaultValue(index);
}