|  |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							|  |  |  | import 'package:firebase_core/firebase_core.dart'; | 
					
						
							|  |  |  | import 'package:firebase_messaging/firebase_messaging.dart'; | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/app_state.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/dependencies.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/utils.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/doctor_filter/doctor_filter_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/insurance/insurance_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/lab/history/lab_history_viewmodel.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/radiology/radiology_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/routes/app_routes.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/services/logger_service.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/services/navigation_service.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/theme/app_theme.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/date_range_selector/viewmodel/date_range_view_model.dart' show DateRangeSelectorRangeViewModel; | 
					
						
							|  |  |  | import 'package:provider/provider.dart'; | 
					
						
							|  |  |  | import 'package:provider/single_child_widget.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'core/utils/size_utils.dart'; | 
					
						
							|  |  |  | import 'firebase_options.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pragma('vm:entry-point') | 
					
						
							|  |  |  | Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { | 
					
						
							|  |  |  |   await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); | 
					
						
							|  |  |  |   getIt.get<LoggerService>().logInfo("Firebase backgroundMessageHandler Main!!!"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyHttpOverrides extends HttpOverrides { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   HttpClient createHttpClient(SecurityContext? context) { | 
					
						
							|  |  |  |     return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Future<void> callAppStateInitializations() async { | 
					
						
							|  |  |  |   final String deviceTypeId = (Platform.isIOS | 
					
						
							|  |  |  |       ? "1" | 
					
						
							|  |  |  |       : await Utils.isGoogleServicesAvailable() | 
					
						
							|  |  |  |           ? "2" | 
					
						
							|  |  |  |           : "3"); | 
					
						
							|  |  |  |   AppState appState = getIt.get<AppState>(); | 
					
						
							|  |  |  |   appState.setDeviceTypeID = deviceTypeId; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Future<void> callInitializations() async { | 
					
						
							|  |  |  |   WidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  |   await EasyLocalization.ensureInitialized(); | 
					
						
							|  |  |  |   await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); | 
					
						
							|  |  |  |   AppDependencies.addDependencies(); | 
					
						
							|  |  |  |   SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); | 
					
						
							|  |  |  |   HttpOverrides.global = MyHttpOverrides(); | 
					
						
							|  |  |  |   await callAppStateInitializations(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void main() async { | 
					
						
							|  |  |  |   await callInitializations(); | 
					
						
							|  |  |  |   runApp( | 
					
						
							|  |  |  |     EasyLocalization( | 
					
						
							|  |  |  |       supportedLocales: const <Locale>[ | 
					
						
							|  |  |  |         Locale('en', 'US'), | 
					
						
							|  |  |  |         Locale('ar', 'SA'), | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       path: 'assets/langs', | 
					
						
							|  |  |  |       fallbackLocale: Locale('en', 'US'), | 
					
						
							|  |  |  |       child: MultiProvider(providers: <SingleChildWidget>[ | 
					
						
							|  |  |  |         ChangeNotifierProvider<LabViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<LabViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<RadiologyViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<RadiologyViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<PrescriptionsViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<PrescriptionsViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<InsuranceViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<InsuranceViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<MedicalFileViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<MedicalFileViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<ProfileSettingsViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<ProfileSettingsViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<MyAppointmentsViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<MyAppointmentsViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<PayfortViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<PayfortViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<HabibWalletViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<HabibWalletViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<BookAppointmentsViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<BookAppointmentsViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<ImmediateLiveCareViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<ImmediateLiveCareViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<AuthenticationViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<AuthenticationViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<AppointmentViaRegionViewmodel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<AppointmentViaRegionViewmodel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<LabHistoryViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<LabHistoryViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<DateRangeSelectorRangeViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<DateRangeSelectorRangeViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<DoctorFilterViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<DoctorFilterViewModel>(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         ChangeNotifierProvider<EmergencyServicesViewModel>( | 
					
						
							|  |  |  |           create: (_) => getIt.get<EmergencyServicesViewModel>(), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |       ], child: MyApp()), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyApp extends StatelessWidget { | 
					
						
							|  |  |  |   const MyApp({super.key}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return SafeArea( | 
					
						
							|  |  |  |       top: false, // Set to true if you want to avoid the notch area as well
 | 
					
						
							|  |  |  |       bottom: Platform.isIOS ? false : true, | 
					
						
							|  |  |  |       child: LayoutBuilder( | 
					
						
							|  |  |  |         builder: (context, constraints) { | 
					
						
							|  |  |  |           return Sizer( | 
					
						
							|  |  |  |             builder: (context, orientation, deviceType) { | 
					
						
							|  |  |  |               // SizeConfig().init(constraints, orientation);
 | 
					
						
							|  |  |  |               return MaterialApp( | 
					
						
							|  |  |  |                 title: 'Dr. AlHabib', | 
					
						
							|  |  |  |                 builder: (context, mchild) { | 
					
						
							|  |  |  |                   return MediaQuery( | 
					
						
							|  |  |  |                       data: MediaQuery.of(context).copyWith( | 
					
						
							|  |  |  |                         textScaler: TextScaler.linear(1.0), | 
					
						
							|  |  |  |                       ), | 
					
						
							|  |  |  |                       child: mchild!); | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 showSemanticsDebugger: false, | 
					
						
							|  |  |  |                 debugShowCheckedModeBanner: false, | 
					
						
							|  |  |  |                 localizationsDelegates: context.localizationDelegates, | 
					
						
							|  |  |  |                 supportedLocales: context.supportedLocales, | 
					
						
							|  |  |  |                 locale: context.locale, | 
					
						
							|  |  |  |                 initialRoute: AppRoutes.initialRoute, | 
					
						
							|  |  |  |                 routes: AppRoutes.routes, | 
					
						
							|  |  |  |                 theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"), | 
					
						
							|  |  |  |                 navigatorKey: getIt.get<NavigationService>().navigatorKey, | 
					
						
							|  |  |  |               ); | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |           ); | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // flutter pub run easy_localization:generate -S assets/langs -f keys -o locale_keys.g.dart
 |