forEachIndexed method

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

forEach() that also gives the index. items.forEachIndexed((i, e) => print("$i $e"))

Implementation

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