Skip to content

Instantly share code, notes, and snippets.

@yishingene
Created June 1, 2019 15:32
Show Gist options
  • Save yishingene/2073dec067d31911cdf36a93b07b765c to your computer and use it in GitHub Desktop.
Save yishingene/2073dec067d31911cdf36a93b07b765c to your computer and use it in GitHub Desktop.
Future, implement using async, await
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