forEachIndexed method

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

Generate forEach but gives index for each element

Implementation

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