-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice.dart
61 lines (49 loc) · 1.23 KB
/
practice.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
//1588313921
void main(){
// getAddressFromLocation();
getDate();
//List<bool> pressed = new List(10);
//for(int i=0;i<pressed.length;i++){
// pressed[i] = false;
//}
//print(pressed);
}
//"lat":19.04,"lon":72.92
void getDate(){
DateTime date = DateTime.fromMillisecondsSinceEpoch(1588363200*1000);
String time = DateFormat('EEE').format(date);
print(time);
}
Future<void> getData() async {
http.Response response = await http.get('https://api.openweathermap.org/data/2.5/onecall?lat=60.99&lon=30.9&appid=b19f23d6304b17aaad167dcc2167f210');
String body = response.body;
var value = jsonDecode(body);
print(value['hourly'][0]['temp']);
// print('/01n');
}
void performTasks() async {
task1();
String r = await task2();
task3(r);
}
void task1() {
String result = 'This is task1.';
print(result);
}
Future task2() async {
Duration duration1 = Duration(seconds: 3);
String result;
/* sleep(duration);*/
await Future.delayed(duration1,(){
result = 'This is task2.';
print(result);
});
return result;
}
void task3(String re) {
String result = 'This is task3 with result from $re .';
print(result);
}