Last active
June 19, 2019 16:26
-
-
Save legalcodes/b8d026d2b23102084534159fafc9d7c6 to your computer and use it in GitHub Desktop.
getUserOrder asynchronous
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
// Asynchronous | |
Future<String> createOrderMessage () async { | |
var order = await getUserOrder(); | |
return 'Your order is: $order'; | |
} | |
// Asynchronous | |
Future<String> getUserOrder() { | |
return Future.delayed(Duration(seconds: 4), () => 'Large Latte'); | |
} | |
// Asynchronous | |
main() async { | |
print("Fetching user order..."); | |
var orderMessage = await createOrderMessage(); | |
print(orderMessage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment