Analog of Promise.all in Dart?
Asked Answered
W

2

36

Is there an existing API to group a list of Future object into one so that I can wait for all to complete? Like in javascript's Promise.all.

Winona answered 11/9, 2019 at 12:28 Comment(3)
Something like Future.wait? api.dart.dev/stable/2.5.0/dart-async/Future/wait.htmlMolina
definitely something like this, please fire an answerWinona
Related question: https://mcmap.net/q/129790/-dartlang-wait-more-than-one-future/9157799Quiberon
M
50

You can use the Future.wait method documented here:

https://api.dart.dev/stable/dart-async/Future/wait.html

Molina answered 11/9, 2019 at 13:6 Comment(0)
D
25

You can use Future.wait

Example

var futures = await Future.wait([     
      getAddress(),      
      getTeam(),    
      getEvents(),
    ]);
Dorindadorine answered 25/5, 2021 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.