Created
April 6, 2026 12:09
-
-
Save phyowaikyaw-mobiledev/657988df3d83ae2a87bd35214ab8bf4b to your computer and use it in GitHub Desktop.
Assignment 19 - Async Programming with Future.wait
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| Future<int> getNumber1() async { | |
| await Future.delayed(Duration(seconds: 3)); | |
| return 10; | |
| } | |
| Future<int> getNumber2() async { | |
| await Future.delayed(Duration(seconds: 2)); | |
| return 20; | |
| } | |
| void main() async { | |
| final result = (await Future.wait([getNumber1(), getNumber2()])).reduce((a, b) => a + b); | |
| print(result); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment