nc-photos/lib/iterator_extension.dart
2022-02-08 19:35:55 +08:00

13 lines
251 B
Dart

extension IteratorExtionsion<T> on Iterator<T> {
void iterate(void Function(T obj) fn) {
while (moveNext()) {
fn(current);
}
}
List<T> toList() {
final list = <T>[];
iterate((obj) => list.add(obj));
return list;
}
}