I need to track progress of resolved futures, is there a way to do it? if not, please add such feature.
That's a fairly specialized requirement.
You have a set of futures that you are waiting on, and you want a to somehow get notified when any of the futures complete. I'm guessing for a progress bar?
I wouldn't add such functionality to the platform libraries. It might fit in package:async, say, as a specialized version of FutureGroup which reports on the status of the futures.
Until then, it's very easy to write yourself, and that also allows you to get exactly the API you need for your use-case:
Future<List<T>> progressWait<T>(List<Future<T>> futures, void progress(int completed, int total)) {
int total = futures.length;
int completed = 0;
void complete() {
completed++;
progress(completed, total);
}
return Future.wait<T>([for (var future in futures) future.whenComplete(complete)]);
}
Most helpful comment
That's a fairly specialized requirement.
You have a set of futures that you are waiting on, and you want a to somehow get notified when any of the futures complete. I'm guessing for a progress bar?
I wouldn't add such functionality to the platform libraries. It might fit in
package:async, say, as a specialized version ofFutureGroupwhich reports on the status of the futures.Until then, it's very easy to write yourself, and that also allows you to get exactly the API you need for your use-case: