indexIndexed<T, K> function
Indexes values into a Map by unique indexed key.
Implementation
Map<K, T> indexIndexed<T, K>(
Iterable<T> values,
K Function(T value, int index, Iterable<T> values) key,
) {
final map = <K, T>{};
var i = -1;
for (final v in values) {
final k = key(v, ++i, values);
if (map.containsKey(k)) throw StateError('duplicate key');
map[k] = v;
}
return map;
}