forEachIndexed method

void forEachIndexed(
  1. void action(
    1. int index,
    2. T element
    )
)

Performs the given action on each element, providing sequential index with the element. @param action function that takes the index of an element and the element itself and performs the desired action on the element.

Implementation

void forEachIndexed(void Function(int index, T element) action) {
  var index = 0;
  for (final item in iter) {
    action(index++, item);
  }
}