map<T, R> static method

List<R> map<T, R>(
  1. Iterable<T> list,
  2. R callback(
    1. T value,
    2. int index
    )
)

Maps each element of list through callback, passing the index too.

Implementation

static List<R> map<T, R>(
  Iterable<T> list,
  R Function(T value, int index) callback,
) {
  var i = 0;
  return [for (final v in list) callback(v, i++)];
}