elementAtOrNull method
Returns an element at the given index
or null
if the index
is out of bounds of this collection.
Implementation
T? elementAtOrNull(int index) {
if (index < 0) {
return null;
}
final i = iterator();
int count = 0;
while (i.hasNext()) {
final element = i.next();
if (index == count++) {
return element;
}
}
return null;
}