elementAtOrNull method
Returns an element at the given index
or null
if the index
is out of
bounds of this collection.
var list = [1, 2, 3, 4];
var first = list.elementAtOrNull(0); // 1
var fifth = list.elementAtOrNull(4); // null
Implementation
E? elementAtOrNull(int index) {
return elementAtOrElseNullable(index, (_) => null);
}