distinct method
Returns a subset of this Iterable containing every element whose key is not equal to the key of any previous element.
If keySelector
is null, the element itself is considered as key.
Implementation
Iterable<TValue> distinct([Function(TValue)? keySelector]) sync* {
final keys = [];
for (final element in this) {
final key = (keySelector == null) ? element : keySelector(element);
if (keys.contains(key)) continue;
keys.add(key);
yield element;
}
}