Skip to content

Commit 96eaf42

Browse files
authored
Add files via upload
1 parent f7e7458 commit 96eaf42

File tree

2 files changed

+315
-0
lines changed

2 files changed

+315
-0
lines changed

lib/countrydata.dart

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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 'search.dart';
6+
7+
class CountryData extends StatefulWidget {
8+
@override
9+
_CountryDataState createState() => _CountryDataState();
10+
}
11+
12+
class _CountryDataState extends State<CountryData> {
13+
14+
List countryData;
15+
fetchCountryData() async {
16+
http.Response response = await http.get("https://www.disease.sh/v2/countries");
17+
setState(() {
18+
countryData = jsonDecode(response.body);
19+
});
20+
}
21+
22+
23+
@override
24+
void initState() {
25+
fetchCountryData();
26+
super.initState();
27+
}
28+
29+
30+
@override
31+
Widget build(BuildContext context) {
32+
return Scaffold(
33+
appBar: new AppBar(
34+
title: new Text("Country Stats",style: TextStyle(fontSize: 20,fontWeight: FontWeight.bold,color: Colors.white),),
35+
actions: <Widget>[
36+
new Padding(padding: const EdgeInsets.symmetric(horizontal: 5)),
37+
IconButton(icon: new Icon(Icons.search), onPressed: (){
38+
showSearch(context: context, delegate: Search(CountryList:countryData));
39+
})
40+
],
41+
),
42+
body: countryData == null ? new Center(
43+
child: new CircularProgressIndicator(),
44+
) : ListView.builder(
45+
itemCount: countryData.length,
46+
itemBuilder: (context , index) =>
47+
new Card(
48+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
49+
color: Color(0x000080),
50+
child: new Row(
51+
crossAxisAlignment: CrossAxisAlignment.start,
52+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
53+
children: <Widget>[
54+
new Column(
55+
children: <Widget>[
56+
new Padding(padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 5)),
57+
new Text(countryData[index]['country'],style: TextStyle(fontSize: 15,fontWeight: FontWeight.bold,color: Colors.white),),
58+
new Image.network(countryData[index]['countryInfo']['flag'],height: 50,width: 60,),
59+
],
60+
),
61+
new Column(
62+
children: <Widget>[
63+
new Padding(padding: const EdgeInsets.only(top: 10)),
64+
new Row(
65+
children: <Widget>[
66+
new Text("CONFIRMED: "+countryData[index]['cases'].toString(),style: TextStyle(fontSize: 15,color: Colors.red,fontWeight: FontWeight.bold),),
67+
new Padding(padding: const EdgeInsets.symmetric(horizontal: 10)),
68+
new Icon(Icons.arrow_upward,color: Colors.red,size: 15,),
69+
new Text(countryData[index]['todayCases'].toString(),style: TextStyle(fontSize: 15,color: Colors.red,fontWeight: FontWeight.bold),),
70+
],
71+
),
72+
new Padding(padding: const EdgeInsets.only(top: 10)),
73+
new Text("ACTIVE: "+countryData[index]['active'].toString(),style: TextStyle(fontSize: 15,color: Colors.blue,fontWeight: FontWeight.bold),),
74+
new Padding(padding: const EdgeInsets.only(top: 10)),
75+
new Row(
76+
children: <Widget>[
77+
new Text("RECOVERED: "+countryData[index]['recovered'].toString(),style: TextStyle(fontSize: 15,color: Colors.green,fontWeight: FontWeight.bold),),
78+
new Padding(padding: const EdgeInsets.symmetric(horizontal: 10)),
79+
new Icon(Icons.arrow_upward,color: Colors.green,size: 15,),
80+
new Text(countryData[index]['todayRecovered'].toString(),style: TextStyle(fontSize: 15,color: Colors.green,fontWeight: FontWeight.bold),),
81+
],
82+
),
83+
new Padding(padding: const EdgeInsets.only(top: 10)),
84+
new Row(
85+
children: <Widget>[
86+
new Text("DEATHS: "+countryData[index]['deaths'].toString(),style: TextStyle(fontSize: 15,color: Colors.black,fontWeight: FontWeight.bold),),
87+
new Padding(padding: const EdgeInsets.symmetric(horizontal: 10)),
88+
new Icon(Icons.arrow_upward,color: Colors.black,size: 15,),
89+
new Text(countryData[index]['todayDeaths'].toString(),style: TextStyle(fontSize: 15,color: Colors.black,fontWeight: FontWeight.bold),),
90+
],
91+
),
92+
new Padding(padding: const EdgeInsets.only(bottom: 10)),
93+
],
94+
)
95+
],
96+
),
97+
)
98+
),
99+
);
100+
}
101+
}

lib/main.dart

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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

Comments
 (0)