Skip to content

Instantly share code, notes, and snippets.

@nsmirosh
Last active August 15, 2020 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsmirosh/d3d3d55f5eb0af20cdd9738574ae42d3 to your computer and use it in GitHub Desktop.
Save nsmirosh/d3d3d55f5eb0af20cdd9738574ae42d3 to your computer and use it in GitHub Desktop.
Dart's await demo
void main() async {
final myFuture = _runTheFuture();
print('myFuture.runtimeType: ${myFuture.runtimeType}');
}
_runTheFuture() async {
print('print statement before invoking the future');
final myValue = await Future.delayed(Duration(seconds: 2), () {
print('Future completed!');
return 12;
});
print('Future value: $myValue');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment