forEachIndexedWhile method

void forEachIndexedWhile(
  1. bool action(
    1. int index,
    2. E element
    )
)

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, E element) action) {
  for (var index = 0; index < length; index++) {
    if (!action(index, this[index])) break;
  }
}