Commit 233464ef authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

90% done in get data from ApI

parent 92e94b98
import 'package:covidefender/EAnalyzer/AddLocation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
...@@ -34,11 +35,10 @@ class _HospitalDetailsState extends State<HospitalDetails> { ...@@ -34,11 +35,10 @@ class _HospitalDetailsState extends State<HospitalDetails> {
Future getData() async{ Future getData() async{
http.Response response = await http.get("https://reqres.in/api/users?page=2"); http.Response response = await http.get("https://www.hpb.health.gov.lk/api/get-current-statistical");
data = json.decode(response.body); data = json.decode(response.body);
setState(() { setState(() {
userData = data["data"]; userData = data["data"]["hospital_data"];
}); });
debugPrint(userData.toString()); debugPrint(userData.toString());
} }
...@@ -67,20 +67,20 @@ class _HospitalDetailsState extends State<HospitalDetails> { ...@@ -67,20 +67,20 @@ class _HospitalDetailsState extends State<HospitalDetails> {
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
CircleAvatar( // CircleAvatar(
backgroundImage: NetworkImage(userData[index]["avatar"]) , // backgroundImage: NetworkImage(userData[index]["avatar"]) ,
), // ),
Padding( Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Text("${userData[index]["first_name"]} ${userData[index]["last_name"]}", child: Text("Hospital ID: ${userData[index]["hospital_id"]}\n${userData[index]["hospital"]["name"]}\n${userData[index]["hospital"]["name_si"]}\n\nTotal Patients: ${userData[index]["cumulative_total"]}\nDate/Time: ${userData[index]["created_at"]}",
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
),), ),),
), ),
Text("${userData[index]["id"]}"), // Text("\n\n\n\n\n\n\n\n\n${userData[index]["created_at"]}"),
Text("${userData[index]["email"]}"), // Text("${userData[index]["email"]}"),
], ],
), ),
), ),
...@@ -121,9 +121,9 @@ class _HospitalDetailsState extends State<HospitalDetails> { ...@@ -121,9 +121,9 @@ class _HospitalDetailsState extends State<HospitalDetails> {
} }
//-----------------------------------------Class Hospital-------------------------------------------------- //-----------------------------------------Class Hospital--------------------------------------------------
class Hospital{ // class Hospital{
final String updateDateTime; // final String date;
final String localNewCases; // final String count;
// final String hospitalId; // final String hospitalId;
// final String hospital; // final String hospital;
// final String cumulativeLocal; // final String cumulativeLocal;
...@@ -131,5 +131,5 @@ class Hospital{ ...@@ -131,5 +131,5 @@ class Hospital{
// final String createdAt; // final String createdAt;
//Hospital(this.hospitalId,this.hospital,this.cumulativeLocal,this.cumulativeForeign,this.createdAt); //Hospital(this.hospitalId,this.hospital,this.cumulativeLocal,this.cumulativeForeign,this.createdAt);
Hospital(this.updateDateTime,this.localNewCases); // Hospital(this.date,this.count);
} // }
\ No newline at end of file \ 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