toMap<K, V> method

Map<K, V> toMap<K, V>(
  1. K key(
    1. T
    ),
  2. V value(
    1. T
    )
)

Convert the list to a Map with key and value functions. Returns a new Map with the keys and values returned by key and value.

Implementation

Map<K, V> toMap<K, V>(K Function(T) key, V Function(T) value) {
  final map = <K, V>{};
  for (final item in this) {
    map[key(item)] = value(item);
  }
  return map;
}