groupBy<K> method
Groups elements by a computed key.
Example:
users.groupBy((u) => u.role);
Implementation
Map<K, List<T>> groupBy<K>(K Function(T e) key) {
final map = <K, List<T>>{};
for (final e in this) {
map.putIfAbsent(key(e), () => []).add(e);
}
return map;
}