1
+ import 'package:flutter/cupertino.dart' ;
2
+ import 'package:flutter/material.dart' ;
3
+ import 'package:http/http.dart' as http;
4
+ import 'dart:convert' ;
5
+ import 'countrydata.dart' ;
6
+ import 'faqs.dart' ;
7
+
8
+
9
+
10
+ void main () => runApp (MyApp ());
11
+
12
+ class MyApp extends StatelessWidget {
13
+ @override
14
+ Widget build (BuildContext context) {
15
+ return MaterialApp (
16
+ debugShowCheckedModeBanner: false ,
17
+ theme: new ThemeData (
18
+ brightness: Brightness .dark,
19
+ ),
20
+ home: HomePage (),
21
+ );
22
+ }
23
+ }
24
+
25
+ class HomePage extends StatefulWidget {
26
+ @override
27
+ _HomePageState createState () => _HomePageState ();
28
+ }
29
+
30
+ class _HomePageState extends State <HomePage > {
31
+
32
+ Map worldData;
33
+ fetchWorldWideData () async {
34
+ http.Response response = await http.get ("https://www.disease.sh/v2/all" );
35
+ setState (() {
36
+ worldData = json.decode (response.body);
37
+ });
38
+ }
39
+
40
+
41
+ @override
42
+ void initState () {
43
+ fetchWorldWideData ();
44
+ super .initState ();
45
+ }
46
+
47
+ @override
48
+ Widget build (BuildContext context) {
49
+ return Scaffold (
50
+ appBar: new AppBar (
51
+ title: new Text ("COVID19 TRACKING APP" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
52
+ ),
53
+ drawer : new Drawer (
54
+ child: new ListView (
55
+ children: < Widget > [
56
+ new UserAccountsDrawerHeader (
57
+ accountName: new Text ("COVID19 Tracking App" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
58
+ accountEmail: new Text ("covid19help@gmail.com" ,style: TextStyle (fontSize: 15 ,color: Colors .white),),
59
+ currentAccountPicture: new CircleAvatar (
60
+ backgroundColor: Colors .red[400 ],
61
+ child: new Text ("CT" ,style: TextStyle (color: Colors .white,fontWeight: FontWeight .bold),),
62
+ ) ,
63
+ ),
64
+ new ListTile (
65
+ title: new Text ("Worldwide Stats" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
66
+ trailing: new Icon (Icons .show_chart,size: 20 ,color: Colors .white,),
67
+ onTap: (){
68
+ Navigator .push (context, MaterialPageRoute (builder: (BuildContext context)=> HomePage () ));
69
+ },
70
+ ),
71
+ new Padding (padding: const EdgeInsets .only (top: 10 )),
72
+ new ListTile (
73
+ title: new Text ("Country Stats" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
74
+ trailing: new Icon (Icons .show_chart,size: 20 ,color: Colors .white,),
75
+ onTap: (){
76
+ Navigator .push (context, MaterialPageRoute (builder: (BuildContext context)=> CountryData () ));
77
+ },
78
+ ),
79
+ new Padding (padding: const EdgeInsets .only (top: 10 )),
80
+ new ListTile (
81
+ title: new Text ("FAQs" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
82
+ trailing: new Icon (Icons .arrow_forward,size: 20 ,color: Colors .white,),
83
+ onTap: (){
84
+ Navigator .push (context, MaterialPageRoute (builder: (BuildContext context)=> FaqPage () ));
85
+ },
86
+ ),
87
+ new Padding (padding: const EdgeInsets .only (top: 10 )),
88
+ new Divider (
89
+ height: 10 ,thickness: 2 ,color: Colors .grey[700 ],
90
+ ),
91
+ new Padding (padding: const EdgeInsets .only (top: 10 )),
92
+ new ListTile (
93
+ title: new Text ("Close" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
94
+ trailing: new Icon (Icons .close,size: 20 ,color: Colors .white,),
95
+ onTap: (){
96
+ Navigator .pop (context);
97
+ },
98
+ ),
99
+ ],
100
+ ),
101
+ ),
102
+ body: worldData == null ? new Center (
103
+ child: new CircularProgressIndicator (),
104
+ ) : new Container (
105
+ padding: const EdgeInsets .all (20 ),
106
+ child: new SingleChildScrollView (
107
+ child: new Column (
108
+ children: < Widget > [
109
+ new Padding (padding: const EdgeInsets .only (top: 10 )),
110
+ new Text ("Worldwide" ,style: TextStyle (fontSize: 20 ,color: Colors .white,fontWeight: FontWeight .bold),),
111
+ new Card (
112
+ color: Colors .red[200 ],
113
+ child: new ListTile (
114
+ title: new Text ("CONFIRMED" ,style: TextStyle (fontSize: 20 ,color: Colors .red,fontWeight: FontWeight .bold),),
115
+ subtitle: new Row (
116
+ children: < Widget > [
117
+ new Text (worldData['cases' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .red,fontWeight: FontWeight .bold),),
118
+ new Padding (padding: const EdgeInsets .symmetric (horizontal: 40 )),
119
+ new Icon (Icons .arrow_upward,color: Colors .red,),
120
+ new Text (worldData['todayCases' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .red,fontWeight: FontWeight .bold),)
121
+ ],
122
+ ),
123
+ ),
124
+ shape: new RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
125
+ ),
126
+ new Card (
127
+ color: Colors .blue[200 ],
128
+ child: new ListTile (
129
+ title: new Text ("ACTIVE" ,style: TextStyle (fontSize: 20 ,color: Colors .blue,fontWeight: FontWeight .bold),),
130
+ subtitle: new Text (worldData['active' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .blue,fontWeight: FontWeight .bold),),
131
+ ),
132
+ shape: new RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
133
+ ),
134
+ new Card (
135
+ color: Colors .green[200 ],
136
+ child: new ListTile (
137
+ title: new Text ("RECOVERED" ,style: TextStyle (fontSize: 20 ,color: Colors .green,fontWeight: FontWeight .bold),),
138
+ subtitle: new Row (
139
+ children: < Widget > [
140
+ new Text (worldData['recovered' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .green,fontWeight: FontWeight .bold),),
141
+ new Padding (padding: const EdgeInsets .symmetric (horizontal: 40 )),
142
+ new Icon (Icons .arrow_upward,color: Colors .green,),
143
+ new Text (worldData['todayRecovered' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .green,fontWeight: FontWeight .bold),)
144
+ ],
145
+ )
146
+ ),
147
+ shape: new RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
148
+ ),
149
+ new Card (
150
+ color: Colors .grey,
151
+ child: new ListTile (
152
+ title: new Text ("DEATHS" ,style: TextStyle (fontSize: 20 ,color: Colors .black,fontWeight: FontWeight .bold),),
153
+ subtitle: new Row (
154
+ children: < Widget > [
155
+ new Text (worldData['deaths' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .black,fontWeight: FontWeight .bold),),
156
+ new Padding (padding: const EdgeInsets .symmetric (horizontal: 60 )),
157
+ new Icon (Icons .arrow_upward,color: Colors .black,),
158
+ new Text (worldData['todayDeaths' ].toString (),style: TextStyle (fontSize: 20 ,color: Colors .black,fontWeight: FontWeight .bold),)
159
+ ],
160
+ )
161
+ ),
162
+ shape: new RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
163
+ ),
164
+ new Padding (padding : const EdgeInsets .only (top: 40 )),
165
+ new MaterialButton (
166
+ color: Color (0x000080 ),
167
+ child: new Row (
168
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
169
+ children: < Widget > [
170
+ new Padding (padding: const EdgeInsets .symmetric (vertical: 20 )),
171
+ new Text ("FAQs" ,style: TextStyle (fontSize: 25 ,fontWeight: FontWeight .bold,color: Colors .white),),
172
+ new Icon (Icons .arrow_forward),
173
+ ],
174
+ ),
175
+ onPressed: (){
176
+ Navigator .push (context, MaterialPageRoute (builder: (BuildContext context)=> FaqPage () ));
177
+ },
178
+ shape: RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
179
+ ),
180
+ new MaterialButton (
181
+ color: Color (0x000080 ),
182
+ child: new Row (
183
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
184
+ children: < Widget > [
185
+ new Padding (padding: const EdgeInsets .symmetric (vertical: 20 )),
186
+ new Text ("Donate" ,style: TextStyle (fontSize: 25 ,fontWeight: FontWeight .bold,color: Colors .white),),
187
+ new Icon (Icons .arrow_forward),
188
+ ],
189
+ ),
190
+ onPressed: () {},
191
+ shape: RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
192
+ ),
193
+ new MaterialButton (
194
+ color: Color (0x000080 ),
195
+ child: new Row (
196
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
197
+ children: < Widget > [
198
+ new Padding (padding: const EdgeInsets .symmetric (vertical: 20 )),
199
+ new Text ("Country Stats" ,style: TextStyle (fontSize: 25 ,fontWeight: FontWeight .bold,color: Colors .white),),
200
+ new Icon (Icons .arrow_forward),
201
+ ],
202
+ ),
203
+ onPressed: (){
204
+ Navigator .push (context, MaterialPageRoute (builder: (BuildContext context) => CountryData () ));
205
+ },
206
+ shape: RoundedRectangleBorder (borderRadius: BorderRadius .all (Radius .circular (10 ))),
207
+ ),
208
+ ],
209
+ ),
210
+ )
211
+ ),
212
+ );
213
+ }
214
+ }
0 commit comments