distinctBy method
Returns a list of unique elements based on a selector function.
Example:
var list = [{'id': 1}, {'id': 1}, {'id': 2}];
var result = list.distinctBy((e) => e['id']); // [{'id': 1}, {'id': 2}]
Implementation
List<T> distinctBy(Object? Function(T e) selector) {
final set = <Object?>{};
return where((e) => set.add(selector(e))).toList();
}