elementAtOrNull method
- int index
The index
th 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.
Implementation
E? elementAtOrNull(int index) => (index < length) ? this[index] : null;