Last active
July 11, 2019 23:04
-
-
Save legalcodes/8f4d136e7eb447f4acc7ccb523006e10 to your computer and use it in GitHub Desktop.
getUserOrder synchronous
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
// Synchronous | |
String createOrderMessage () { | |
var order = getUserOrder(); | |
return 'Your order is: $order'; | |
} | |
Future<String> getUserOrder() { | |
// Imagine that this function is more complex and slow | |
return Future.delayed(Duration(seconds: 4), () => 'Large Latte'); | |
} | |
// Synchronous | |
main() { | |
print("Fetching user order..."); | |
print(createOrderMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment