Commit c4281225 authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Get no of infected people due to current date

parent c4d536dc
// import 'dart:convert';
// import 'dart:html';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'dart:convert';
import 'dart:ffi';
......@@ -9,6 +10,7 @@ import 'package:flutter/material.dart';
// import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:http/http.dart' as http;
import 'package:quiver/testing/time.dart';
import 'package:intl/intl.dart';
class SearchEvent extends StatefulWidget {
......@@ -26,6 +28,8 @@ class _SearchEventState extends State<SearchEvent> {
String noOfPeople;
int ima;
//final List<String> dist = ['ampara', 'anuradhapura', 'badulla', 'batticaloa','colombo','galle','gampaha','hambantota','jaffna','kalmunai','kalutara','kandy','kegalle','kilinochchi','kurunagala','mannar','matale','matara','monaragala','mullaitivu','nuwara eliya','polonnaruwa','puttalam','ratnapura','trincomalee','vavuniya'];
var finalRisk = 'rrrr';
......@@ -33,9 +37,9 @@ class _SearchEventState extends State<SearchEvent> {
var tcVisibility = false;
DateTime now = new DateTime.now();
Duration dur = new Duration(days: 1);
// Duration dur = new Duration(days: 1);
//var yesterday = now.subtract(const Duration(days: 1));
// var yesterday = now.subtract(const Duration(days: 1));
// var formatterDate = new DateFormat('dd');
// var formatterMonth = new DateFormat('MM');
// var formatterYear = new DateFormat('yyyy');
......@@ -75,6 +79,39 @@ class _SearchEventState extends State<SearchEvent> {
this.noOfPeople= noOfPeople;
}
getNumberOfcases(String district) async{
DateTime now = new DateTime.now();
//Duration dur = new Duration(days: 1);
var yesterday = now.subtract(const Duration(days: 1));
// String year = yesterday.year.toString();
// String month = yesterday.month.toString();
// String date = yesterday.day.toString();
String formattedDate = new DateFormat('yyyy-MM-dd').format(yesterday);
// // String riskLevelDocument = location + '_' + formattedDate;
// // var formatterDate = new DateFormat('dd');
// // var formatterMonth = new DateFormat('MM');
// // var formatterYear = new DateFormat('yyyy');
// // String date = formatterDate.format(yesterday);
// // String month = formatterMonth.format(yesterday);
// String year = formatterYear.format(yesterday);
String riskLevelDocument = district + '_' + formattedDate;
// var a = Firestore.instance.collection('RiskLevel').document(riskLevelDocument)
// .get().then(function(Document) =>
// print(Document("cases"));
// );
DocumentSnapshot querySnapshot = await Firestore.instance.collection("RiskLevel").document(riskLevelDocument).get();
Map<String, dynamic> data = querySnapshot.data();
// val = querySnapshot.documents.length;
// var val = data['cases'];
// String riskLevelDocument = location + finalDate;
this.noOfInfected = data['cases'];
print(noOfInfected);
// return data['cases'].toString();
}
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
......@@ -157,6 +194,7 @@ Widget _buildDistrict(){
},
onChanged: (String district){
getDistrict(district);
getNumberOfcases(district);
},
);
}
......@@ -189,7 +227,14 @@ Widget _buildNoOfInfected(){
// },
onChanged: (String noOfInfected){
getInfected(noOfInfected);
// DocumentReference documentReference = Firestore.instance.collection('RiskLevel').document('district');
// print(documentReference);
},
// Firestore.instance.collection('COLLECTION').document('ID').get().then((DocumentSnapshot) =>
// print(DocumentSnapshot.data['key'].toString());
// );
);
}
......@@ -295,7 +340,7 @@ Future<void> check() async{
print(reText);
tcVisibility = true;
print('$now');
print(now.subtract(dur));
//print(now.subtract(dur));
}
......
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