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:cloud_firestore/cloud_firestore.dart';
// import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:http/http.dart' as http;
class SearchEvent extends StatefulWidget {
......@@ -11,9 +19,9 @@ class _SearchEventState extends State<SearchEvent> {
String hotelName;
String district;
int noOfInfected;
int nearToDistrict;
int noOfPeople;
String noOfInfected;
String nearToDistrict;
String noOfPeople;
// int ima;
......@@ -30,7 +38,7 @@ class _SearchEventState extends State<SearchEvent> {
this.district= district;
}
getDate(noOfInfected){
getInfected(noOfInfected){
this.noOfInfected= noOfInfected;
}
......@@ -145,10 +153,10 @@ Widget _buildNoOfInfected(){
}
},
// onSaved: (String value){
// _fName = value;
// noOfInfected = value;
// },
onChanged: (String noOfInfected){
getNearDistrict(noOfInfected);
getInfected(noOfInfected);
},
);
}
......@@ -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
Widget build(BuildContext context) {
......@@ -262,9 +296,14 @@ Widget _buildNoOfPeople(){
style: TextStyle(color: Colors.white, fontSize: 30),
),
onPressed: () {
if(!_formKey.currentState.validate()) {
return;
}
// if(!_formKey.currentState.validate()) {
// 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();
} ,
),
......
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