withProgress<T, R> method
Process a list of items with a progress bar Returns a list of results from processing each item
Implementation
Future<List<R>> withProgress<T, R>({
required List<T> items,
required Future<R> Function(T item, int index) process,
String? message,
String? completionMessage,
}) async {
final progress = ConsoleProgressBar(total: items.length, message: message);
progress.start();
final results = <R>[];
for (int i = 0; i < items.length; i++) {
final result = await process(items[i], i);
results.add(result);
progress.tick();
}
progress.complete(completionMessage);
return results;
}