Skip to content

Instantly share code, notes, and snippets.

@Mol0ko
Created June 9, 2021 12:41
Show Gist options
  • Save Mol0ko/07eafa79ebcb9f391e494199f13594e0 to your computer and use it in GitHub Desktop.
Save Mol0ko/07eafa79ebcb9f391e494199f13594e0 to your computer and use it in GitHub Desktop.
Future, async, await example
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