Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save azenla/4edc243dfada8b9e0fad to your computer and use it in GitHub Desktop.
Save azenla/4edc243dfada8b9e0fad to your computer and use it in GitHub Desktop.
class FutureGroup {
Completer _completer = new Completer();
List<Future> _futures = new List<Future>();
FutureGroup();
bool add(Future future) {
if(!_futures.contains(future)) {
_futures.add(future);
return true;
}
return false;
}
Future wait() {
Future.wait(_futures).then((result) {
_completer.complete();
})..catchError((err) => _completer.completeError(err));
return _completer.future;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment