distinctBy<K> method
Returns a list with duplicates removed by keyOf, preserving order.
Implementation
List<T> distinctBy<K>(K Function(T element) keyOf) {
final seen = <K>{};
final output = <T>[];
for (final element in this) {
final key = keyOf(element);
if (seen.add(key)) {
output.add(element);
}
}
return output;
}