toMapWith method

Map<K, V> toMapWith(
  1. K keyOf(
    1. T
    ),
  2. V valueOf(
    1. T
    )
)

Builds a map from keyOf and valueOf for each element; later elements overwrite.

Implementation

Map<K, V> toMapWith(K Function(T) keyOf, V Function(T) valueOf) {
  final Map<K, V> out = <K, V>{};
  for (final T e in this) {
    out[keyOf(e)] = valueOf(e);
  }
  return out;
}