Commit 4bd0762c authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Change normal methods to state method

parent f472cba6
......@@ -83,7 +83,7 @@ class _SearchEventState extends State<SearchEvent> {
DateTime now = new DateTime.now();
//Duration dur = new Duration(days: 1);
var yesterday = now.subtract(const Duration(days: 2));
var yesterday = now.subtract(const Duration(days: 3));
// String year = yesterday.year.toString();
// String month = yesterday.month.toString();
// String date = yesterday.day.toString();
......@@ -118,12 +118,12 @@ Map<String, dynamic> data = querySnapshot.data();
void checkMethodSimple(int value) {
}
// @override
// void initState() {
// riskLevel();
// // TODO: implement initState
// super.initState();
// }
@override
void initState() {
// TODO: implement initState
super.initState();
}
......@@ -215,7 +215,7 @@ Widget _buildNoOfInfected(){
),
prefixIcon: Icon(Icons.people_outlined),
hintText: "No Of Infected people",
labelText: noOfInfected
labelText: this.noOfInfected
),
// ignore: missing_return
validator: (String value){
......@@ -228,13 +228,13 @@ Widget _buildNoOfInfected(){
// },
onChanged: (String noOfInfected){
getInfected(noOfInfected);
setState(() {
});
// DocumentReference documentReference = Firestore.instance.collection('RiskLevel').document('district');
// print(documentReference);
},
// Firestore.instance.collection('COLLECTION').document('ID').get().then((DocumentSnapshot) =>
// print(DocumentSnapshot.data['key'].toString());
// );
);
}
......@@ -314,6 +314,8 @@ Future Getdata(url) async{
}
Future<void> check() async{
setState(() async{
String urls = 'https://eanalyzer.herokuapp.com/api/eanalyzer?NoInfected='+noOfInfected.toString()+'&NearToDistrict='+nearToDistrict.toString()+'&NoOfPeople='+noOfPeople.toString();
var Data = await Getdata(urls);
var reText = jsonDecode(Data);
......@@ -341,6 +343,8 @@ Future<void> check() async{
print(reText);
tcVisibility = true;
print('$now');
});
//print(now.subtract(dur));
}
......@@ -367,6 +371,14 @@ Future<void> check() async{
SizedBox(height: 10),
_buildDistrict(),
SizedBox(height: 10),
new RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.green)),
child: new Text('View No of Infected People',textAlign: TextAlign.center,
style: TextStyle(color: Colors.green[900], fontSize: 17),),
onPressed: voteUp,
),
SizedBox(height: 10),
_buildNoOfInfected(),
SizedBox(height: 10),
_buildNearToDistrict(),
......@@ -417,6 +429,8 @@ Future<void> check() async{
onPressed: () {
check();
Visibility();
voteUp();
// if(!_formKey.currentState.validate()) {
// return;
......@@ -431,9 +445,41 @@ Future<void> check() async{
),
SizedBox(height: 20),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.blue[900])),
padding: EdgeInsets.all(15.0),
color: Colors.blue[900],
child: Text(
'View Risk Level',textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 30),
),
onPressed: voteUp,
),
// new Text('Up Votes: $votes'),
// new RaisedButton(
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0),
// side: BorderSide(color: Colors.green[900])),
// child: new Text('Vote up'),
// onPressed: voteUp,
// ),
],
),),
),
);
}
int votes = 0;
void voteUp() {
setState(() {
votes = votes + 1;
});
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment