distinctBy<K> method
Removes duplicates by a field, keeping the first. users.distinctBy((u) => u.id)
Implementation
List<T> distinctBy<K>(K Function(T item) key) {
final Set<K> seen = <K>{};
return where((T item) => seen.add(key(item))).toList();
}