mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-21 07:58:13 +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;
|
||
|
}
|
||
|
}
|