removeDuplicates<R> method

Iterable<E> removeDuplicates<R>([
  1. R key(
    1. E
    )?
])

Implementation

Iterable<E> removeDuplicates<R>([R Function(E)? key]) {
  if (isEmpty) return this;
  if (isPrimitive) return toSet();
  if (key == null) return this;
  final map = fold<Map<R, E>>({}, (map, item) {
    map[key(item)] = item;
    return map;
  });
  return map.values;
}