whereIndexed method
Returns a new iterable containing elements that satisfy the test with their index.
Example:
[10, 20, 30].whereIndexed((i, e) => i > 0); // [20, 30]
Implementation
Iterable<T> whereIndexed(bool Function(int index, T element) test) sync* {
var index = 0;
for (var element in this) {
if (test(index++, element)) {
yield element;
}
}
}