mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-19 07:03:37 +00:00
9 lines
234 B
Dart
9 lines
234 B
Dart
extension Unique<E, Id> on List<E> {
|
|
List<E> unique([Id Function(E element)? id]) {
|
|
final ids = <dynamic>{};
|
|
final list = [...this];
|
|
list.retainWhere((x) => ids.add(id != null ? id(x) : x as Id));
|
|
return list;
|
|
}
|
|
}
|