Created
February 28, 2020 08:06
-
-
Save JannieT/20ae2ced5f4d5dfc760339b4de6584f5 to your computer and use it in GitHub Desktop.
This file contains 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 main() async { | |
print('start'); | |
final futures = <Future>[ | |
fetchLong(), | |
fetchShort(), | |
]; | |
await Future.wait(futures); | |
print('all done'); | |
} | |
Future<void> fetchShort() { | |
return Future.delayed(Duration(seconds: 4), () => print('Short!')); | |
} | |
Future<void> fetchLong() { | |
return Future.delayed(Duration(seconds: 5), () => print('Long!')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment