groupByKey method
Groups the list elements according to a specified key in each element.
key
is the key to group by.
Example:
final groupedByKey = list.groupByKey("category");
Implementation
Map<T, List<T>> groupByKey(String key) => groupBy((T e) {
if (e is Map && e.containsKey(key)) {
return e[key] as T;
}
throw ArgumentError('Key not found: $key');
});