Created
June 9, 2021 12:41
-
-
Save Mol0ko/07eafa79ebcb9f391e494199f13594e0 to your computer and use it in GitHub Desktop.
Future, async, await example
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
void main() async { | |
print('Fetching user profile...'); | |
print(await fetchUserProfile()); | |
} | |
Future<Map<String, dynamic>> fetchUserProfile() async { | |
await Future.delayed(Duration(seconds: 2)); | |
return {'id': 12345, 'name': 'John'}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment