nth method
Returns the nth element of the iterator. Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on. nth() will return None if n is greater than or equal to the length of the iterator.
Implementation
T? nth(int n) {
if (n < 0) {
return null;
}
var index = 0;
for (final element in this) {
if (index == n) {
return element;
}
index++;
}
return null;
}