Skip to content

Instantly share code, notes, and snippets.

@marcel-ploch
Created May 3, 2022 12:48
Show Gist options
  • Save marcel-ploch/664a3fc188d694d5b1644774d09d6922 to your computer and use it in GitHub Desktop.
Save marcel-ploch/664a3fc188d694d5b1644774d09d6922 to your computer and use it in GitHub Desktop.
Future<void> printOrderMessage() async {
print('Awaiting user order...');
var order = await fetchUserOrder();
print('Your order is: $order');
}
Future<String> fetchUserOrder() {
// Imagine that this function is more complex and slow.
return Future.delayed(const Duration(seconds: 4), () => 'Large Latte');
}
void main() async {
await printOrderMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment