-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratch.dart
43 lines (35 loc) · 847 Bytes
/
scratch.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
void main() {
performTasks();
}
void performTasks() async {
task1();
String task2Data = await task2();
task3(task2Data);
}
void task1() {
print('Task 1 complete');
}
Future<String> task2() async {
Duration threeSeconds = Duration(seconds: 3);
// sleep(threeSeconds);
String result;
await Future.delayed(threeSeconds, () {
result = 'task 2 data';
print('Task 2 complete');
});
return result;
}
void task3(task2Data) {
print('Task 3 complete with $task2Data');
}
//void getLocation() async {
//
// Complex syntax :
// Position position = Position();
// position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
//
// Simpler syntax:
// Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
// print(position);
//
//}