Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. void main() {
  2. var futureObject = getPostFromServer();
  3. printPost(futureObject);
  4. }
  5.  
  6. getPostFromServer() async {
  7. var duration = Duration(seconds: 5);
  8. var computation = () {
  9. return "You will get it in future";
  10. };
  11.  
  12. var futureObject = await Future.delayed(duration, computation);
  13. return futureObject;
  14. }
  15.  
  16. printPost(var futureObject) async {
  17. print(await futureObject);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement