SHARE
TWEET

Untitled

a guest Jul 17th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top