groupBy<S> method

Map<S, List<T>> groupBy<S>(
  1. S key(
    1. T
    )
)

Implementation

Map<S, List<T>> groupBy<S>(S Function(T) key) {
  var map = <S, List<T>>{};
  for (var element in this) {
    (map[key(element)] ??= []).add(element);
  }
  return map;
}