remove double future builds

This commit is contained in:
2024-08-23 16:45:48 +02:00
parent 26586db61a
commit 16893e2b9a

View File

@@ -2,7 +2,6 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/mihAppDrawer.dart'; import 'package:patient_manager/components/mihAppDrawer.dart';
import 'package:patient_manager/components/mihLoadingCircle.dart';
import 'package:patient_manager/components/patientDetails.dart'; import 'package:patient_manager/components/patientDetails.dart';
import 'package:patient_manager/components/mihAppBar.dart'; import 'package:patient_manager/components/mihAppBar.dart';
import 'package:patient_manager/components/patientFiles.dart'; import 'package:patient_manager/components/patientFiles.dart';
@@ -67,26 +66,16 @@ class _PatientViewState extends State<PatientView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
// loadImage(); // loadImage();
// var logo = MzanziInnovationHub.of(context)!.theme.logoImage(); // var logo = MzanziInnovationHub.of(context)!.theme.logoImage();
return FutureBuilder(
future: fetchPatient(),
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Mihloadingcircle();
}
// Checking if future is resolved
else if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
return Scaffold( return Scaffold(
appBar: const MIHAppBar(barTitle: "Patient View"), appBar: const MIHAppBar(barTitle: "Patient View"),
drawer: showDrawer(), drawer: showDrawer(),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
vertical: 10.0, horizontal: 15.0),
child: Column( child: Column(
children: [ children: [
PatientDetails( PatientDetails(
selectedPatient: snapshot.data!, selectedPatient: widget.arguments.selectedPatient!,
type: widget.arguments.type, type: widget.arguments.type,
), ),
const SizedBox( const SizedBox(
@@ -101,8 +90,8 @@ class _PatientViewState extends State<PatientView> {
SizedBox( SizedBox(
width: 660, width: 660,
child: PatientNotes( child: PatientNotes(
patientAppId: snapshot.data!.app_id, patientAppId: widget.arguments.selectedPatient!.app_id,
selectedPatient: snapshot.data!, selectedPatient: widget.arguments.selectedPatient!,
signedInUser: widget.arguments.signedInUser, signedInUser: widget.arguments.signedInUser,
business: widget.arguments.business, business: widget.arguments.business,
businessUser: widget.arguments.businessUser, businessUser: widget.arguments.businessUser,
@@ -112,8 +101,9 @@ class _PatientViewState extends State<PatientView> {
SizedBox( SizedBox(
width: 660, width: 660,
child: PatientFiles( child: PatientFiles(
patientIndex: snapshot.data!.idpatients, patientIndex:
selectedPatient: snapshot.data!, widget.arguments.selectedPatient!.idpatients,
selectedPatient: widget.arguments.selectedPatient!,
signedInUser: widget.arguments.signedInUser, signedInUser: widget.arguments.signedInUser,
business: widget.arguments.business, business: widget.arguments.business,
businessUser: widget.arguments.businessUser, businessUser: widget.arguments.businessUser,
@@ -129,13 +119,3 @@ class _PatientViewState extends State<PatientView> {
); );
} }
} }
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
);
},
);
}
}