1
0
Fork 0
mirror of https://gitlab.com/nkming2/nc-photos.git synced 2025-03-31 12:31:35 +02:00
nc-photos/lib/list_extension.dart

10 lines
279 B
Dart
Raw Normal View History

2021-04-10 12:28:12 +08:00
extension ListExtension<T> on List<T> {
/// Return a new list with only distinct elements
List<T> distinct() {
final s = Set();
return this.where((element) => s.add(element)).toList();
}
Iterable<T> takeIndex(List<int> indexes) => indexes.map((e) => this[e]);
}