Created
April 30, 2020 03:06
-
-
Save samramez/a209381bff8a8061be6dbff2338f9e2d to your computer and use it in GitHub Desktop.
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
// Sample Dart code for making parallel async calls. | |
void main() { | |
Future.wait([firstAsync(), secondAsync(), thirdAsync()]) | |
.then((List responses) => print("All tasks are done")) | |
.catchError((e) => print(e)); | |
} | |
Future firstAsync() async { | |
print("firstAsync started"); | |
await Future<String>.delayed(const Duration(seconds: 3)); | |
print("firstAsync DONE"); | |
} | |
Future secondAsync() async { | |
print("secondAsync started"); | |
await Future<String>.delayed(const Duration(seconds: 3)); | |
print("secondAsync DONE"); | |
} | |
Future thirdAsync() async { | |
print("thirdAsync started"); | |
await Future<String>.delayed(const Duration(seconds: 3)); | |
print("thirdAsync DONE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment