countBy static method
counts the occurrences of values in the list if condition satisified
Example:
countBy(list, fn)
Implementation
static Map<dynamic, dynamic> countBy(
Iterable<dynamic> itr, dynamic Function(dynamic) fn) {
// ignore: always_specify_types
return Map.fromIterable(itr.map(fn).toSet(),
// ignore: always_specify_types
value: (i) => itr.where((v) => fn(v) == i).length);
}