Last active
August 15, 2020 11:59
-
-
Save nsmirosh/d3d3d55f5eb0af20cdd9738574ae42d3 to your computer and use it in GitHub Desktop.
Dart's await demo
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 { | |
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