diff --git a/lib/features/habib_wallet/habib_wallet_view_model.dart b/lib/features/habib_wallet/habib_wallet_view_model.dart index 00ba55cc..5605281d 100644 --- a/lib/features/habib_wallet/habib_wallet_view_model.dart +++ b/lib/features/habib_wallet/habib_wallet_view_model.dart @@ -30,6 +30,7 @@ class HabibWalletViewModel extends ChangeNotifier { num habibWalletAmount = 0; num walletRechargeAmount = 0; String notesText = ""; + bool isWalletAmountToBeLoaded = true; bool isBottomSheetContentLoading = false; @@ -392,6 +393,11 @@ class HabibWalletViewModel extends ChangeNotifier { notifyListeners(); } + setIsWalletAmountToBeLoaded(bool value) { + isWalletAmountToBeLoaded = value; + notifyListeners(); + } + String getSelectedRechargeTypeValue() { switch (selectedRechargeType) { case 1: @@ -406,6 +412,9 @@ class HabibWalletViewModel extends ChangeNotifier { } Future getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async { + if (!isWalletAmountToBeLoaded) { + return; + } isWalletAmountLoading = true; notifyListeners(); @@ -425,6 +434,7 @@ class HabibWalletViewModel extends ChangeNotifier { habibWalletBalanceList.removeWhere((element) => element.patientAdvanceBalanceAmount == 0); isWalletAmountLoading = false; + isWalletAmountToBeLoaded = false; notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); @@ -462,12 +472,7 @@ class HabibWalletViewModel extends ChangeNotifier { Function(dynamic)? onSuccess, Function(String)? onError}) async { final result = await habibWalletRepo.HISCreateAdvancePayment( - paymentMethodName: paymentMethodName, - paidAmount: paidAmount, - paymentReference: paymentReference, - patientID: patientID, - projectID: projectID, - depositorName: depositorName); + paymentMethodName: paymentMethodName, paidAmount: paidAmount, paymentReference: paymentReference, patientID: patientID, projectID: projectID, depositorName: depositorName); result.fold( // (failure) async => await errorHandlerService.handleError(failure: failure), @@ -489,8 +494,7 @@ class HabibWalletViewModel extends ChangeNotifier { ); } - Future addAdvanceNumberRequest( - {required String advanceNumber, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async { + Future addAdvanceNumberRequest({required String advanceNumber, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async { final result = await habibWalletRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference); result.fold( @@ -538,8 +542,7 @@ class HabibWalletViewModel extends ChangeNotifier { lakumAccountInfo = LakumInquiryInformationResponseModel(); notifyListeners(); - final result = await habibWalletRepo.getLakumAccountInformation( - identificationNumber: getIt.get().getAuthenticatedUser()!.patientIdentificationNo ?? ""); + final result = await habibWalletRepo.getLakumAccountInformation(identificationNumber: getIt.get().getAuthenticatedUser()!.patientIdentificationNo ?? ""); result.fold( (failure) async => await errorHandlerService.handleError(failure: failure),