import 'package:nc_photos/override_comparator.dart'; extension ListExtension on List { /// Return a new list with only distinct elements List distinct() { final s = {}; return where((element) => s.add(element)).toList(); } /// Return a new list with only distinct elements determined by [equalFn] List distinctIf( bool Function(T a, T b) equalFn, int Function(T a) hashCodeFn) { final s = >{}; return where((element) => s.add(OverrideComparator(element, equalFn, hashCodeFn))).toList(); } Iterable takeIndex(List indexes) => indexes.map((e) => this[e]); }