group<GK> method

Map<GK, List<E>> group<GK>(
  1. GK groupKeyProvider(
    1. E item
    )
)

Implementation

Map<GK, List<E>> group<GK>(GK Function(E item) groupKeyProvider)
{
  Map<GK, List<E>> map = {};

  if (this == null) {
    return map;
  }

  for (var item in this!) {
    GK key = groupKeyProvider(item);
    map.putIfAbsent(key, () => []).add(item);
  }

  return map;
}