toMap<K> method

Map<K, E> toMap<K>(
  1. K getKey(
    1. E
    )
)

Creates a map from this Iterable using it's value as map values and results of getKey as keys.

The code is:

{
  for (final value in this)
    getKey(value): value,
}

Implementation

Map<K, E> toMap<K>(K Function(E) getKey) {
  return {
    for (final value in this) getKey(value): value,
  };
}