distinctByTo<K> method
Populates and returns the destination
list with containing only
elements from the given iterable having distinct keys returned by
the given selector
function.
Implementation
Iterable<E> distinctByTo<K>(
List<E> destination, K Function(E element) selector) {
final set = HashSet<K>();
for (var element in this) {
final key = selector(element);
if (set.add(key)) destination.add(element);
}
return destination;
}