Commit 20521bef authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Connect Flutter app to python model

parent c9037d98
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
\ No newline at end of file
// import 'dart:convert';
// import 'dart:html';
import 'dart:convert';
import 'dart:ffi';
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;
class SearchEvent extends StatefulWidget { class SearchEvent extends StatefulWidget {
...@@ -11,9 +19,9 @@ class _SearchEventState extends State<SearchEvent> { ...@@ -11,9 +19,9 @@ class _SearchEventState extends State<SearchEvent> {
String hotelName; String hotelName;
String district; String district;
int noOfInfected; String noOfInfected;
int nearToDistrict; String nearToDistrict;
int noOfPeople; String noOfPeople;
// int ima; // int ima;
...@@ -30,7 +38,7 @@ class _SearchEventState extends State<SearchEvent> { ...@@ -30,7 +38,7 @@ class _SearchEventState extends State<SearchEvent> {
this.district= district; this.district= district;
} }
getDate(noOfInfected){ getInfected(noOfInfected){
this.noOfInfected= noOfInfected; this.noOfInfected= noOfInfected;
} }
...@@ -145,10 +153,10 @@ Widget _buildNoOfInfected(){ ...@@ -145,10 +153,10 @@ Widget _buildNoOfInfected(){
} }
}, },
// onSaved: (String value){ // onSaved: (String value){
// _fName = value; // noOfInfected = value;
// }, // },
onChanged: (String noOfInfected){ onChanged: (String noOfInfected){
getNearDistrict(noOfInfected); getInfected(noOfInfected);
}, },
); );
} }
...@@ -215,6 +223,32 @@ Widget _buildNoOfPeople(){ ...@@ -215,6 +223,32 @@ Widget _buildNoOfPeople(){
); );
} }
Future Getdata(url) async{
http.Response Response = await http.get(url);
return Response.body;
}
Future<void> check() 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);
print(reText);
// var ex = [2];
if(reText.toString() == '[0]') {
print("Low Risk");
}
else if(reText.toString() == '[1]') {
print("Moderate Risk");
}
else if(reText.toString() == '[2]') {
print("High Risk");
}
// print("sss");
// print(reText);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -262,9 +296,14 @@ Widget _buildNoOfPeople(){ ...@@ -262,9 +296,14 @@ Widget _buildNoOfPeople(){
style: TextStyle(color: Colors.white, fontSize: 30), style: TextStyle(color: Colors.white, fontSize: 30),
), ),
onPressed: () { onPressed: () {
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();
// var Data = await Getdata(urls);
// var reText = jsonDecode(Data);
check();
// riskLevel(); // riskLevel();
} , } ,
), ),
......
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