Created
June 1, 2019 15:32
-
-
Save yishingene/2073dec067d31911cdf36a93b07b765c to your computer and use it in GitHub Desktop.
Future, implement using async, await
This file contains hidden or 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
| import 'dart:async'; | |
| main() async { | |
| print('about to fetch data!'); | |
| var result = await get('http://www.google.com'); | |
| print(result); | |
| } | |
| Future<String> get(String url){ | |
| return new Future.delayed( | |
| new Duration(seconds:3),(){ | |
| return 'Got the data! after 3 seconds'; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment