toMap<K, V> method
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;
}