mapWithIndex<B> method

Iterable<B> mapWithIndex<B>(
  1. B toElement(
    1. T t,
    2. int index
    )
)

Same as map but provides also the index of each mapped element in the mapping function (toElement).

Implementation

Iterable<B> mapWithIndex<B>(B Function(T t, int index) toElement) sync* {
  var index = 0;
  for (var value in this) {
    yield toElement(value, index);
    index += 1;
  }
}