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 'dart:async';
import 'dart:convert';
......@@ -34,11 +35,10 @@ class _HospitalDetailsState extends State<HospitalDetails> {
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);
setState(() {
userData = data["data"];
userData = data["data"]["hospital_data"];
});
debugPrint(userData.toString());
}
......@@ -67,20 +67,20 @@ class _HospitalDetailsState extends State<HospitalDetails> {
padding: const EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
CircleAvatar(
backgroundImage: NetworkImage(userData[index]["avatar"]) ,
),
// CircleAvatar(
// backgroundImage: NetworkImage(userData[index]["avatar"]) ,
// ),
Padding(
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(
fontSize: 18.0,
fontWeight: FontWeight.w700,
),),
),
Text("${userData[index]["id"]}"),
Text("${userData[index]["email"]}"),
// Text("\n\n\n\n\n\n\n\n\n${userData[index]["created_at"]}"),
// Text("${userData[index]["email"]}"),
],
),
),
......@@ -121,9 +121,9 @@ class _HospitalDetailsState extends State<HospitalDetails> {
}
//-----------------------------------------Class Hospital--------------------------------------------------
class Hospital{
final String updateDateTime;
final String localNewCases;
// class Hospital{
// final String date;
// final String count;
// final String hospitalId;
// final String hospital;
// final String cumulativeLocal;
......@@ -131,5 +131,5 @@ class Hospital{
// final String createdAt;
//Hospital(this.hospitalId,this.hospital,this.cumulativeLocal,this.cumulativeForeign,this.createdAt);
Hospital(this.updateDateTime,this.localNewCases);
}
\ No newline at end of file
// Hospital(this.date,this.count);
// }
\ 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