Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement