Future.wait and Parallel Work
Run multiple futures concurrently.
Future.wait and Parallel Work is a free Dart Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Awaiting One by One Is Slow
Awaiting futures in sequence makes each one wait for the last. Three one-second calls then take three seconds total.
Start Them Together
Kick off independent async calls first, then await them. They run concurrently, so total time tracks the slowest, not the sum.
Meet Future.wait
Future.wait takes a list of futures and returns one future that completes when all of them finish.
final results = await Future.wait([a(), b(), c()]);Results Stay in Order
Future.wait gives you a list of results in the same order as the input futures, no matter which finished first.
final list = await Future.wait([one(), two()]);
print(list[0]); // result of one()Real Time Savings
Three parallel one-second futures finish together in about one second, since Future.wait overlaps the waiting.
If One Fails
By default, if any future errors, Future.wait completes with that error immediately, even if others were still running.
Keep Going With eagerError
Pass eagerError: false and Future.wait still waits for every future before reporting the first error it saw.
await Future.wait(tasks, eagerError: false);Racing With Future.any
Need just the fastest result? Future.any completes as soon as the first future in the list succeeds.
final fastest = await Future.any([mirrorA(), mirrorB()]);Building the List
A common pattern is map over your inputs to create a list of futures, then pass that straight to Future.wait.
await Future.wait(ids.map(fetchUser));Concurrent, Not Parallel Threads
This is concurrency on one isolate: the event loop interleaves the waiting. For CPU-heavy work you would reach for isolates.
When to Use Each
Use Future.wait when you need all results, and Future.any when you only need the first one to arrive. ⚖️
Quick Check
Quick check on running futures together.
Recap: Parallel Futures
You learned to overlap async work with Future.wait for all results, Future.any for the fastest, and how errors behave. 🏁
Frequently asked questions
Is the “Future.wait and Parallel Work” lesson free?
Yes — the full text of “Future.wait and Parallel Work” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.
What will I learn in “Future.wait and Parallel Work”?
Run multiple futures concurrently. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Dart Academy?
No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Future.wait and Parallel Work” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Dart Academy lesson?
Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Event Loop and Microtasks
- Creating and Awaiting Futures
- Error Handling in async Code
- Future.wait and Parallel Work