elementAtOrNull method
Returns an element at the given index
or null
if the index
is out of
bounds of this collection.
Implementation
E? elementAtOrNull(int index) {
final iterator = this.iterator;
var elementIndex = 0;
while (iterator.moveNext()) {
if (index == elementIndex) return iterator.current;
elementIndex++;
}
return null;
}