Commit d3200455 authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Display final risk in flutter app

parent e72701b5
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi'; import 'dart:ffi';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:cloud_firestore/cloud_firestore.dart'; // import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
...@@ -22,6 +23,11 @@ class _SearchEventState extends State<SearchEvent> { ...@@ -22,6 +23,11 @@ class _SearchEventState extends State<SearchEvent> {
String noOfInfected; String noOfInfected;
String nearToDistrict; String nearToDistrict;
String noOfPeople; String noOfPeople;
int ima;
var finalRisk = 'rrrr';
var tcVisibility = false;
// int ima; // int ima;
...@@ -222,7 +228,7 @@ Widget _buildNoOfPeople(){ ...@@ -222,7 +228,7 @@ Widget _buildNoOfPeople(){
}, },
); );
} }
//------------------------------------------------Connect to Model---------------------------------------------------------------------
Future Getdata(url) async{ Future Getdata(url) async{
http.Response Response = await http.get(url); http.Response Response = await http.get(url);
return Response.body; return Response.body;
...@@ -236,18 +242,25 @@ Future<void> check() async{ ...@@ -236,18 +242,25 @@ Future<void> check() async{
// var ex = [2]; // var ex = [2];
//-----------------------------------------------------OutPut------------------------------------------------------------------------------ //-----------------------------------------------------OutPut------------------------------------------------------------------------------
if(reText.toString() == '[0]') { if(reText.toString() == '[0]') {
print("Low Risk"); print("This is a Low Risk area");
reText = "Low Risk";
finalRisk = reText;
ima = 101;
} }
else if(reText.toString() == '[1]') { else if(reText.toString() == '[1]') {
print("Moderate Risk"); print("This is a Moderate Risk area");
reText = "Moderate Risk";
finalRisk = reText;
ima = 102;
} }
else if(reText.toString() == '[2]') { else if(reText.toString() == '[2]') {
print("High Risk"); print("This is a High Risk area");
reText = "High Risk";
finalRisk = reText;
ima = 103;
} }
// print("sss"); print(reText);
tcVisibility = true;
// print(reText);
} }
...@@ -277,15 +290,35 @@ Future<void> check() async{ ...@@ -277,15 +290,35 @@ Future<void> check() async{
_buildNearToDistrict(), _buildNearToDistrict(),
SizedBox(height: 10), SizedBox(height: 10),
_buildNoOfPeople(), _buildNoOfPeople(),
SizedBox(height: 50),
//Image(image: AssetImage('lib/assets/images/200.gif')),
// Image.asset('lib/assets/images/101.gif',fit: BoxFit.contain,width: 150,height: 150,),
// Center(
// child:
// Text('This is a $finalRisk area',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold, color: Colors.red[900]),)),
// SizedBox(height: 10),
Visibility(
visible: tcVisibility,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Image.asset(
'lib/assets/images/$ima.gif',
fit: BoxFit.contain,width: 150,height: 150,
),
),
Text('This is a $finalRisk area',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold, color: Colors.red[900]),),
],
)
),
SizedBox(height: 30),
SizedBox(height: 50),
//Image(image: AssetImage('lib/assets/images/200.gif')),
Image.asset('lib/assets/images/200.gif',fit: BoxFit.contain,width: 150,height: 150,),
Center(child:
Text('This is a risk area',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold, color: Colors.red[900]),)),
SizedBox(height: 10),
RaisedButton( RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0), borderRadius: BorderRadius.circular(18.0),
...@@ -297,13 +330,14 @@ Future<void> check() async{ ...@@ -297,13 +330,14 @@ Future<void> check() async{
style: TextStyle(color: Colors.white, fontSize: 30), style: TextStyle(color: Colors.white, fontSize: 30),
), ),
onPressed: () { onPressed: () {
check();
// if(!_formKey.currentState.validate()) { // if(!_formKey.currentState.validate()) {
// return; // return;
//} //}
//String urls = 'https://eanalyzer.herokuapp.com/api/eanalyzer?NoInfected='+noOfInfected.toString()+'&NearToDistrict='+nearToDistrict.toString()+'&NoOfPeople='+noOfPeople.toString(); //String urls = 'https://eanalyzer.herokuapp.com/api/eanalyzer?NoInfected='+noOfInfected.toString()+'&NearToDistrict='+nearToDistrict.toString()+'&NoOfPeople='+noOfPeople.toString();
// var Data = await Getdata(urls); // var Data = await Getdata(urls);
// var reText = jsonDecode(Data); // var reText = jsonDecode(Data);
check();
// riskLevel(); // riskLevel();
} , } ,
......
...@@ -86,7 +86,9 @@ flutter: ...@@ -86,7 +86,9 @@ flutter:
- lib/assets/images/feedback80.png - lib/assets/images/feedback80.png
- lib/assets/images/list80.png - lib/assets/images/list80.png
- lib/assets/images/search80.png - lib/assets/images/search80.png
- lib/assets/images/200.gif - lib/assets/images/101.gif
- lib/assets/images/102.gif
- lib/assets/images/103.gif
- lib/assets/images/cdlogo.png - lib/assets/images/cdlogo.png
- lib/assets/images/cdlogo1.png - lib/assets/images/cdlogo1.png
- lib/assets/images/cdlogo2.png - lib/assets/images/cdlogo2.png
......
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