forEachIndexedWhile method Null safety
Takes an action for each element and index as long as desired.
Calls action
for each element along with the index in the
iteration order.
Stops iteration if action
returns false
.
Implementation
void forEachIndexedWhile(bool Function(int index, T element) action) {
var index = 0;
for (var element in this) {
if (!action(index++, element)) break;
}
}