mapIndexed<R> method

List<R> mapIndexed<R>(
  1. R fn(
    1. int i,
    2. T e
    )
)

Maps elements with access to their index.

Example:

list.mapIndexed((i, e) => '$i: $e');

Implementation

List<R> mapIndexed<R>(R Function(int i, T e) fn) {
  var i = 0;
  return map((e) => fn(i++, e)).toList();
}