toMap<K, V> method
Converts the list to Map.
Use collector
to convert each element to a key-value Pair, which represents a map entry.
Implementation
Map<K, V> toMap<K, V>(Pair<K, V>? Function(T element) collector) {
final resultMap = <K, V>{};
for (final element in this) {
final pair = collector(element);
if (pair != null) {
resultMap[pair.key] = pair.value;
}
}
return resultMap;
}