groupBy method
Groups the list elements according to a given condition.
fn
is a function that determines the grouping key for each element.
Example:
final groupedList = list.groupBy((item) => item.category);
Implementation
Map<T, List<T>> groupBy(T Function(T) fn) => Map<T, List<T>>.fromIterable(
map(fn).toSet(),
value: (i) => where((T v) => fn(v) == i).toList(),
);