removeDuplicatedBy<T, U> function
- Iterable<
T> list, - _IterableFunction<
T, U> fn
Remove duplicated values from an iterable given a predicate without modifying the original iterable.
Implementation
Iterable<T> removeDuplicatedBy<T, U>(
Iterable<T> list, _IterableFunction<T, U> fn) {
final values = <U, bool>{};
return list.where((i) {
final value = fn(i);
return values.update(value, (_) => false, ifAbsent: () => true);
}).toList();
}