From 9a23b7dd7c05943b8283d7acbb40072485a697a7 Mon Sep 17 00:00:00 2001 From: "taha.alam" Date: Sun, 24 Aug 2025 15:35:54 +0300 Subject: [PATCH] init state issue resolve --- .../medical/labs/laboratory_result_page.dart | 2 ++ .../LabResult/laboratory_result_widget.dart | 24 ++++++++++++------- lib/widgets/others/app_scaffold_widget.dart | 3 +++ lib/widgets/others/network_base_view.dart | 6 ++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/pages/medical/labs/laboratory_result_page.dart b/lib/pages/medical/labs/laboratory_result_page.dart index 498fcdb6..634220ae 100644 --- a/lib/pages/medical/labs/laboratory_result_page.dart +++ b/lib/pages/medical/labs/laboratory_result_page.dart @@ -39,6 +39,7 @@ class _LaboratoryResultPageState extends State { baseViewModel: model, showNewAppBar: true, showNewAppBarTitle: true, + showLoader: false, backgroundColor: Color(0xffF8F8F8), body: SingleChildScrollView( child: Column( @@ -63,6 +64,7 @@ class _LaboratoryResultPageState extends State { : getSpecialResults(model), orderNo: widget.patientLabOrders!.orderNo, patientLabOrder: widget.patientLabOrders, + labmodel: model ), ], ), diff --git a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart index d4f7a6ee..1028b5a7 100644 --- a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart @@ -20,8 +20,9 @@ class LaboratoryResultWidget extends StatefulWidget { final String? projectName; final PatientLabOrders? patientLabOrder; final bool showConfirmMessageDialog; + final LabsViewModel labmodel; - const LaboratoryResultWidget({Key? key, this.onTap, this.billNo, this.details, this.orderNo, this.projectName, this.patientLabOrder, this.showConfirmMessageDialog = true}) : super(key: key); + const LaboratoryResultWidget({Key? key, this.onTap, this.billNo, this.details, this.orderNo, this.projectName, this.patientLabOrder, this.showConfirmMessageDialog = true,required this.labmodel}) : super(key: key); @override _LaboratoryResultWidgetState createState() => _LaboratoryResultWidgetState(); @@ -37,8 +38,10 @@ class _LaboratoryResultWidgetState extends State { @override void initState() { super.initState(); + this.model = widget.labmodel; - labSpecialResult = widget.details ?? TranslationBase.of(context).noDataAvailable; + print("the details are ${widget.details}"); + labSpecialResult = widget.details; } @@ -67,21 +70,24 @@ class _LaboratoryResultWidgetState extends State { isTabletScreen = isTablet(context); projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) { - this.model = model; - model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!, isTablet: isTabletScreen); + onModelReady: (_) { + print("the length of in on model Ready ${model?.patientLabSpecialResult.length}"); + WidgetsBinding.instance.addPostFrameCallback((_) { + model?.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!, isTablet: isTabletScreen); + }); + }, - builder: (_, model, w) => NetworkBaseView( - baseViewModel: model, + builder: (_, __, w) => NetworkBaseView( + baseViewModel: widget.labmodel, child: Column( mainAxisSize: MainAxisSize.max, children: [ _buildDoctorHeader(), SizedBox(height: 10), - if (model.labResultLists.isNotEmpty) + if (this.model?.labResultLists.isNotEmpty == true) Padding( padding: const EdgeInsets.all(21.0), - child: _buildLabResultsList(model), + child: _buildLabResultsList(model!), ), // Expanded( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 3c186ac9..c61f1add 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -90,6 +90,7 @@ class AppScaffold extends StatefulWidget { final bool resizeToAvoidBottomInset; final bool showCenteredLogo; final bool showLastLoginScreenBar; + final bool showLoader; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -143,6 +144,7 @@ class AppScaffold extends StatefulWidget { this.resizeToAvoidBottomInset = false, this.showCenteredLogo = false, this.showLastLoginScreenBar = false, + this.showLoader = true, }); @override @@ -298,6 +300,7 @@ class _AppScaffoldState extends State { ? NetworkBaseView( child: buildBodyWidget(context), baseViewModel: widget.baseViewModel, + showLoader : widget.showLoader ) : buildBodyWidget(context), ), diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index f9305026..3155656e 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -10,8 +10,9 @@ class NetworkBaseView extends StatefulWidget { final Widget? child; final bool isLocalLoader; final bool? isLoading; + final bool? showLoader; - NetworkBaseView({Key? key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading}); + NetworkBaseView({Key? key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading, this.showLoader = true}); @override _NetworkBaseViewState createState() => _NetworkBaseViewState(); @@ -47,6 +48,9 @@ class _NetworkBaseViewState extends State { } buildBaseViewWidget() { + if(widget.showLoader == false) { + return widget.child; + } switch (widget.baseViewModel!.state) { case ViewState.ErrorLocal: case ViewState.Idle: