elementAtOrNull method

T elementAtOrNull(
  1. int index
)

Returns the indexth element. If the index is out of bounds it will return null.

Example:

['a', 'b'].elementAtOrNull(2); // null

Implementation

T elementAtOrNull(int index) => elementAtOrElse(index, () => null as T);