diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index c394d3f9..6243ab3b 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -4,7 +4,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/core/utils/push_notification_handler.dart b/lib/core/utils/push_notification_handler.dart index 9bf34660..075b982c 100644 --- a/lib/core/utils/push_notification_handler.dart +++ b/lib/core/utils/push_notification_handler.dart @@ -494,7 +494,7 @@ class PushNotificationHandler { log("Push Notification getToken: ${token!}"); onToken(token!); }).catchError((err) { - log(err); + log(err.toString()); }); FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) { diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 066464b9..385d3e76 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -284,10 +284,14 @@ class AuthenticationViewModel extends ChangeNotifier { // Validate based on selected country if (selectedCountrySignup == CountryEnum.saudiArabia) { - if (!ValidationUtils.validateIqama(nationalIdController.text)) { - _nationalIdError = LocaleKeys.pleaseEnterAValidIqamaID.tr(); - notifyListeners(); - return false; + if (cleanedId.length == 10) { + if (!ValidationUtils.validateIqama(nationalIdController.text)) { + _nationalIdError = LocaleKeys.pleaseEnterAValidIqamaID.tr(); + notifyListeners(); + return false; + } + } else { + return true; } } else if (selectedCountrySignup == CountryEnum.unitedArabEmirates) { if (!ValidationUtils.validateUaeNationalId(nationalIdController.text)) { diff --git a/lib/features/book_appointments/book_appointments_view_model.dart b/lib/features/book_appointments/book_appointments_view_model.dart index 1d15fdd2..7ac09686 100644 --- a/lib/features/book_appointments/book_appointments_view_model.dart +++ b/lib/features/book_appointments/book_appointments_view_model.dart @@ -1106,7 +1106,7 @@ class BookAppointmentsViewModel extends ChangeNotifier { docID: selectedDoctor.doctorID!, clinicID: selectedDoctor.clinicID!, projectID: selectedDoctor.projectID!, - serviceID: selectedLiveCareClinic.serviceID!, + serviceID: selectedLiveCareClinic.serviceID ?? 0, selectedDate: selectedAppointmentDate, selectedTime: selectedAppointmentTime, initialSlotDuration: initialSlotDuration, diff --git a/lib/main.dart b/lib/main.dart index 5999a04e..ffe2043e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -96,7 +96,13 @@ Future callAppStateInitializations() async { // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics PlatformDispatcher.instance.onError = (error, stack) { - if (!kDebugMode) FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + if (!kDebugMode) { + FirebaseCrashlytics.instance.recordError(error, stack, + fatal: true, + printDetails: true, + reason: + "${appState.isAuthenticated ? "Authenticated User ID: ${appState.getAuthenticatedUser()!.patientId} - ${appState.getAuthenticatedUser()!.mobileNumber}" : "Unauthenticated User"} - Uncaught asynchronous error"); + } return true; }; } diff --git a/lib/presentation/ask_doctor/doctor_response_page.dart b/lib/presentation/ask_doctor/doctor_response_page.dart index 9cd19ef6..1aed8cfb 100644 --- a/lib/presentation/ask_doctor/doctor_response_page.dart +++ b/lib/presentation/ask_doctor/doctor_response_page.dart @@ -78,7 +78,7 @@ class _DoctorResponsePageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - askDoctorVM.doctorResponsesList[index].requestTypeDescription!.toText18(isBold: true), + (askDoctorVM.doctorResponsesList[index].requestTypeDescription ?? "").toText18(isBold: true), SizedBox(height: 24.h), Row( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 4346d8b5..b740a04f 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -451,7 +451,7 @@ class _LandingPageState extends State { height: isTablet ? 290.h : 255.h, child: ListView.separated( scrollDirection: Axis.horizontal, - itemCount: 3, + itemCount: myAppointmentsVM.patientAppointmentsHistoryList.length < 3 ? myAppointmentsVM.patientAppointmentsHistoryList.length : 3, shrinkWrap: true, padding: EdgeInsets.only(left: 16.h, right: 16.h), itemBuilder: (context, index) { @@ -980,9 +980,14 @@ class _LandingPageState extends State { // ); // } - return _buildAppointmentCardWrapper( - myAppointmentsViewModel.patientAppointmentsHistoryList[1], - ); + // Safety check: ensure list has at least 2 items + if (myAppointmentsViewModel.patientAppointmentsHistoryList.length > 1) { + return _buildAppointmentCardWrapper( + myAppointmentsViewModel.patientAppointmentsHistoryList[1], + ); + } + + return Container(); // Return empty container if not enough items } // Third slot: Shows ancillary orders or appointment @@ -996,9 +1001,14 @@ class _LandingPageState extends State { // ); } - return _buildAppointmentCardWrapper( - myAppointmentsViewModel.patientAppointmentsHistoryList[2], - ); + // Safety check: ensure list has at least 3 items + if (myAppointmentsViewModel.patientAppointmentsHistoryList.length > 2) { + return _buildAppointmentCardWrapper( + myAppointmentsViewModel.patientAppointmentsHistoryList[2], + ); + } + + return Container(); // Return empty container if not enough items } // Queue Card Widget diff --git a/lib/presentation/insurance/insurance_approval_details_page.dart b/lib/presentation/insurance/insurance_approval_details_page.dart index 29663938..c80767eb 100644 --- a/lib/presentation/insurance/insurance_approval_details_page.dart +++ b/lib/presentation/insurance/insurance_approval_details_page.dart @@ -186,7 +186,7 @@ class InsuranceApprovalDetailsPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ "${LocaleKeys.status.tr(context: context)}: ".toText14(isBold: true), - insuranceApprovalResponseModel.apporvalDetails![index]!.status!.toText12(isBold: true, color: AppColors.greyTextColor), + (insuranceApprovalResponseModel.apporvalDetails![index].status ?? "").toText12(isBold: true, color: AppColors.greyTextColor), ], ), SizedBox(height: 8.h), @@ -194,7 +194,7 @@ class InsuranceApprovalDetailsPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ "${LocaleKeys.usageStatus.tr(context: context)}: ".toText14(isBold: true), - (insuranceApprovalResponseModel.apporvalDetails![index]!.isInvoicedDesc ?? "").toText12(isBold: true, color: AppColors.greyTextColor), + (insuranceApprovalResponseModel.apporvalDetails![index].isInvoicedDesc ?? "").toText12(isBold: true, color: AppColors.greyTextColor), ], ), ], diff --git a/lib/widgets/common_bottom_sheet.dart b/lib/widgets/common_bottom_sheet.dart index 8270966f..7b485e75 100644 --- a/lib/widgets/common_bottom_sheet.dart +++ b/lib/widgets/common_bottom_sheet.dart @@ -265,7 +265,7 @@ void showCommonBottomSheetWithoutHeight( builder: (BuildContext context) { if (isAutoDismiss) { Future.delayed(Duration(seconds: 2), () { - Navigator.of(context).pop(); + Navigator.of(GetIt.instance().navigatorKey.currentContext!).pop(); if (callBackFunc != null) { callBackFunc(); }