Created
April 6, 2019 15:50
-
-
Save angelabauer/c19c42b7795a185d2113f3b47263d2c0 to your computer and use it in GitHub Desktop.
Starting Code for Futures/Async/Await Demo
This file contains 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
import 'dart:io'; | |
void main() { | |
performTasks(); | |
} | |
void performTasks() { | |
task1(); | |
task2(); | |
task3(); | |
} | |
void task1() { | |
String result = 'task 1 data'; | |
print('Task 1 complete'); | |
} | |
void task2() { | |
String result = 'task 2 data'; | |
print('Task 2 complete'); | |
} | |
void task3() { | |
String result = 'task 3 data'; | |
print('Task 3 complete'); | |
} |
good and nice try..
the course is outdated it is taking lot of time to debugging null safety
this course needs updates and re-shaping
not working because of null safety
just need to add : late on
Future task2() async {
Duration threeSeconds = Duration(seconds: 3);
late String result;
await Future.delayed(threeSeconds, () {
result = 'task 2 data';
print('Task 2 complete');
});
return result;
}
result =
Task 1 complete
Task 2 complete
Task 3 complete with task 2 data
Process finished with exit code 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good good study
day day up!