associateBy<S> method

Map<S, T> associateBy<S>(
  1. S key(
    1. T
    )
)

Create a map by mapping every element using key. Duplicate values are discarded

Implementation

Map<S, T> associateBy<S>(S Function(T) key) {
  final map = <S, T>{};
  for (final element in this) {
    map[key(element)] = element;
  }
  return map;
}