groupBy<K> method
Groups items by a key. orders.groupBy((o) => o.status) → {paid: ..., pending: ...}
Implementation
Map<K, List<T>> groupBy<K>(K Function(T item) key) {
final Map<K, List<T>> out = <K, List<T>>{};
for (final T item in this) {
(out[key(item)] ??= <T>[]).add(item);
}
return out;
}