forEachWhile method
Takes an action for each element as long as desired.
Calls action
for each element.
Stops iteration if action
returns false
.
Implementation
void forEachWhile(bool Function(T element) action) {
for (var element in this) {
if (!action(element)) break;
}
}