-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a15818
commit 04cb96b
Showing
5 changed files
with
276 additions
and
84 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class CountryPage extends StatefulWidget { | ||
@override | ||
_CountryPageState createState() => _CountryPageState(); | ||
} | ||
|
||
class _CountryPageState extends State<CountryPage> { | ||
List countryData; | ||
fetchCountryData() async { | ||
http.Response response = await http | ||
.get('https://disease.sh/v2/countries?yesterday=false&sort=deaths'); | ||
setState(() { | ||
countryData = json.decode(response.body); | ||
}); | ||
} | ||
|
||
@override | ||
void initState() { | ||
fetchCountryData(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('COUNTRY DATA'), | ||
), | ||
body: countryData == null | ||
? Center( | ||
child: CircularProgressIndicator(), | ||
) | ||
: ListView.builder( | ||
itemBuilder: (context, index) { | ||
return Container( | ||
height: 130, | ||
margin: EdgeInsets.all(10), | ||
decoration: BoxDecoration(color: Colors.white, boxShadow: [ | ||
BoxShadow( | ||
color: Colors.grey[100], | ||
blurRadius: 10, | ||
offset: Offset(0, 10), | ||
), | ||
]), | ||
child: Row( | ||
children: <Widget>[ | ||
Container( | ||
margin: EdgeInsets.symmetric(horizontal: 10), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
Text( | ||
countryData[index]['country'], | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
Image.network( | ||
countryData[index]['countryInfo']['flag'], | ||
height: 40, | ||
width: 60, | ||
) | ||
], | ||
), | ||
), | ||
Expanded( | ||
child: Container( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
Text( | ||
'CONFIRMED ' + | ||
countryData[index]['cases'].toString(), | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
color: Colors.red, | ||
), | ||
), | ||
Text( | ||
'ACTIVE' + | ||
countryData[index]['active'].toString(), | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
color: Colors.blue, | ||
), | ||
), | ||
Text( | ||
'RECOVERED' + | ||
countryData[index]['recovered'].toString(), | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
color: Colors.green, | ||
), | ||
), | ||
Text( | ||
'DEATHS' + | ||
countryData[index]['deaths'].toString(), | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
color: Colors.grey[800], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
}, | ||
itemCount: countryData == null ? 0 : countryData.length, | ||
), | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:covidapp/datasorce.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class FAQPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('FAQs'), | ||
), | ||
body: ListView.builder( | ||
itemCount: DataSource.questionAnswers.length, | ||
itemBuilder: (context, index) { | ||
return ExpansionTile( | ||
title: Text( | ||
DataSource.questionAnswers[index]['question'], | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
children: <Widget>[ | ||
Padding( | ||
padding: EdgeInsets.all(8.0), | ||
child: Text( | ||
DataSource.questionAnswers[index]['answer'], | ||
), | ||
), | ||
], | ||
); | ||
}), | ||
); | ||
} | ||
} |
Oops, something went wrong.