forEachIndexed method

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

Invokes action for each element together with its index.

Example:

['a', 'b'].forEachIndexed((i, v) => print('$i: $v'));

Implementation

void forEachIndexed(void Function(int index, E element) action) {
  int index = 0;
  for (final E element in this) {
    action(index++, element);
  }
}