distinctBy<K> method
Returns a new set with duplicates removed based on the given key
function.
Implementation
Set<E> distinctBy<K>(K Function(E element) key) {
final result = <E>{};
final keys = <K>{};
for (final element in this) {
final k = key(element);
if (keys.add(k)) {
result.add(element);
}
}
return result;
}