distinctBy<K> method
Returns a new list with distinct elements based on key.
users.distinctBy((u) => u.id)
Implementation
List<T> distinctBy<K>(K Function(T) key) {
final seen = <K>{};
return where((e) => seen.add(key(e))).toList();
}