Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import 'dart:io';
  2.  
  3. void main() {
  4. performTask();
  5. }
  6.  
  7. void performTask() async {
  8. task1();
  9. String task2result = await task2();
  10. task3(task2result);
  11. }
  12.  
  13. void task1() {
  14. print('task 1 complete');
  15. }
  16.  
  17. Future task2() async {
  18. Duration threeSeconds = Duration(seconds: 3);
  19. String result;
  20. await Future.delayed(threeSeconds, () {
  21. result = 'task 2 data';
  22. print('task 2 complete');
  23. });
  24. return result;
  25. }
  26.  
  27. void task3(String task2Data) {
  28. String result = 'task 3 data';
  29. print('task 3 complete $task2Data');
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement