elementAtOrNull method

E? elementAtOrNull(
  1. int index

The indexth element, or null if there is no such element.

Returns the element at position index of this list, just like elementAt, if this list has such an element. If this list does not have enough elements to have one with the given index, the null value is returned, unlike elementAt which throws instead.

The index must not be negative.


E? elementAtOrNull(int index) => (index < length) ? this[index] : null;