Created
August 5, 2019 17:25
-
-
Save Abhilash-Chandran/59610dc768e232ac5a8e724f7fe0eee6 to your computer and use it in GitHub Desktop.
For this stack over flow question https://stackoverflow.com/questions/57363039/async-await-not-working-as-expected-it-must-return-me-future-result
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
void main() { | |
var futureObject = getPostFromServer(); | |
printPost(futureObject); | |
} | |
getPostFromServer() async { | |
var duration = Duration(seconds: 5); | |
var computation = () { | |
return "You will get it in future"; | |
}; | |
var futureObject = await Future.delayed(duration, computation); | |
return futureObject; | |
} | |
printPost(var futureObject) async { | |
print(await futureObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment