// import 'dart:async'; // import 'dart:convert'; // import 'dart:io'; // import 'dart:ui'; // import 'package:connectivity_plus/connectivity_plus.dart'; // import 'package:dio/dio.dart'; // import 'package:firebase_core/firebase_core.dart'; // import 'package:firebase_remote_config/firebase_remote_config.dart'; // import 'package:flutter/foundation.dart'; // import 'package:flutter/material.dart'; // import 'package:flutter/services.dart'; // import 'package:flutter/widgets.dart'; // import 'package:hive_flutter/hive_flutter.dart'; // import 'package:konectar_events/contacts_module/constants.dart'; // import 'package:konectar_events/contacts_module/provider_class/affiliationsprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/certificate_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/educationprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/email_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/engagement_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/events_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/hcp%20_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_aff_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_awards_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_certificate_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_education_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_email_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_event_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_list_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_locationprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_pno_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_training_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/location_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/medicalinsightprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/nih_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/patent_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/phoneno_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/procedureprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/publications_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/single_hcpprovider.dart'; // import 'package:konectar_events/contacts_module/provider_class/speaker_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/training_provider.dart'; // import 'package:konectar_events/contacts_module/provider_class/trials_provider.dart'; // import 'package:konectar_events/contacts_module/storage_hive/aff_data/aff_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/awa_data/awa_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/cer_hive/cer_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/edu_data/edu_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/email_data/email_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/events_data/event_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/kol_info/kol_info_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/loc_data/location_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/nih_grant_data/nih_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/patent_data/patent_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/pno_data/pno_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/procedure_data/pro_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/pub_data/pub_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/speaker_data/speaker_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/traning_data/traning_model_hive.dart'; // import 'package:konectar_events/contacts_module/storage_hive/trials_data/trial_model_hive.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/interactionprovider.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/interaction_config_data.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/interaction_data.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/json_form_data.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/save_interaction.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/repository/hive_repository.dart'; // import 'package:konectar_events/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart'; // import 'package:konectar_events/firebaseexample.dart'; // import 'package:konectar_events/model/hive_api_constants.dart'; // import 'package:konectar_events/model/myeventsmodel.dart'; // import 'package:konectar_events/model/neweventsmodel.dart'; // import 'package:konectar_events/model/sessionnotesmodel.dart'; // import 'package:konectar_events/model/userdata_model.dart'; // import 'package:konectar_events/utils/sessionmanager.dart'; // import 'package:konectar_events/view/home.dart'; // import 'package:konectar_events/view/login.dart'; // import 'package:konectar_events/view/login_components/intropaging.dart'; // import 'package:konectar_events/view/navigation_home_screen.dart'; // import 'package:konectar_events/viewmodel/eventsprovider.dart'; // import 'package:konectar_events/viewmodel/hcpprofprovider.dart'; // import 'package:konectar_events/viewmodel/loginprovider.dart'; // import 'package:overlay_support/overlay_support.dart'; // import 'package:provider/provider.dart'; // import 'package:openid_client/openid_client.dart'; // import 'package:flutter_web_plugins/url_strategy.dart'; // import 'package:shared_preferences/shared_preferences.dart'; // //import 'openid/openid_io.dart' if (dart.library.html) 'openid_browser.dart'; // import 'contacts_module/provider_class/award_provider.dart'; // import 'firebase_options.dart'; // import 'package:flutter_background_service/flutter_background_service.dart'; // Future main() async { // WidgetsFlutterBinding.ensureInitialized(); // final dio = Dio(); // await Hive.initFlutter(); // await initializeService(); // Hive.registerAdapter(UserDataAdapter()); // Hive.registerAdapter(EventsListAdapter()); // Hive.registerAdapter(SessionNotesModelAdapter()); // Hive.registerAdapter(MyEventsModelAdapter()); // Hive.registerAdapter(SaveInteractionAdapter()); // Hive.registerAdapter(InteractionConfigDataAdapter()); // Hive.registerAdapter(InteractionResultDataAdapter()); // Hive.registerAdapter(FormFieldDataAdapter()); // Hive.registerAdapter(ValidationAdapter()); // Hive.registerAdapter(SectionListAdapter()); // Hive.registerAdapter(InputClassAdapter()); // Hive.registerAdapter(InteractionWidgetAdapter()); // // Hive.registerAdapter(UserDataAdapter()); // Hive.registerAdapter(SendSaveJsonAdapter()); // Hive.registerAdapter(MultipleSectionListAdapter()); // Hive.registerAdapter(SaveAdapter()); // Hive.registerAdapter(SaveInteractionFormJsonAdapter()); // await Hive.openBox('InteractionDataBox'); // await Hive.openBox('InteractionConfigDataBox'); // var box = await Hive.openBox('mycontact'); // var box1 = await Hive.openBox('myfilter'); // await Hive.openBox('checkvalue'); // await Hive.openBox('hcpdata'); // await Hive.openBox('notehive'); // Hive.registerAdapter(AffiliationAdapter()); // // await Hive.openBox('affiliationshive'); // Hive.registerAdapter(KolInfoAdapter()); // Hive.registerAdapter(PublicationAdapter()); // Hive.registerAdapter(EventsAdapter()); // Hive.registerAdapter(TrialsAdapter()); // Hive.registerAdapter(LocationAdapter()); // Hive.registerAdapter(PhoneNoAdapter()); // Hive.registerAdapter(EmailAdapter()); // Hive.registerAdapter(EduAdapter()); // Hive.registerAdapter(AwaAdapter()); // Hive.registerAdapter(CerAdapter()); // Hive.registerAdapter(PatentAdapter()); // Hive.registerAdapter(NihAdapter()); // Hive.registerAdapter(ProAdapter()); // Hive.registerAdapter(Training1Adapter()); // Hive.registerAdapter(SpeAdapter()); // Hive.registerAdapter(HiveApiConstantsAdapter()); // await Hive.openBox("UserDataBox"); // await Hive.openBox("EventsListBox"); // await Hive.openBox("SessionNotesModelBox"); // await Hive.openBox("MyEventsBox"); // await Hive.openBox("hiveApiConstants"); // WidgetsFlutterBinding.ensureInitialized(); // // FirebaseMessaging.instance.getToken().then((value) { // // String? token = value; // // print("token: $token"); // // }); // usePathUrlStrategy(); // // client = await getClient(); // // //credential = await getRedirectResult(client, scopes: scopes); // // credential = await authenticate(client, scopes: scopes); // // userInfo = await credential!.getUserInfo(); // //runApp(const MyApp()); // // activateTimer(); // SharedPreferences.getInstance().then((instance) { // //StorageService().sharedPreferencesInstance = instance; // bool isloggedIn = instance.getBool('isloggedin') ?? false; // print("checkhere before:$isloggedIn"); // String secretkey = instance.getString('secretkey') ?? ""; // OverlaySupportEntry entry; // Connectivity().onConnectivityChanged.listen((event) { // print("CHECK INTERNET"); // print(event); // if (event.toString().contains("ConnectivityResult.none")) { // entry = showOverlayNotification((context) { // return Text("this is a message from simple notification"); // }, duration: Duration(hours: 1)); // } // }); // OverlaySupport overlaySupport = OverlaySupport.global( // child: Text("ONLINE"), // ); // runApp( // MultiProvider( // providers: [ // ChangeNotifierProvider(create: (_) => LoginProvider()), // ChangeNotifierProvider(create: (_) => EventsProvider()), // ChangeNotifierProvider(create: (_) => HcpProfileProvider()), // //Contacts // ChangeNotifierProvider(create: (_) => InteractionProvider()), // ChangeNotifierProvider(create: (_) => ViewInteractionProvider()), // ChangeNotifierProvider(create: (_) => hcpProvider()), // ChangeNotifierProvider(create: (_) => Singlehcpdetails()), // ChangeNotifierProvider(create: (_) => AffiliationsProvider()), // ChangeNotifierProvider(create: (_) => PublicatioProvider()), // ChangeNotifierProvider(create: (_) => EventProvider()), // ChangeNotifierProvider(create: (_) => TrialsProvider()), // ChangeNotifierProvider(create: (_) => MediacalInsightProvider()), // ChangeNotifierProvider(create: (_) => SpekerEvalutionProvider()), // ChangeNotifierProvider(create: (_) => EnagagementProvider()), // ChangeNotifierProvider(create: (_) => LocationProvider()), // ChangeNotifierProvider(create: (_) => PhonenoProvider()), // ChangeNotifierProvider(create: (_) => EmailProvider()), // ChangeNotifierProvider(create: (_) => PatentProvider()), // ChangeNotifierProvider(create: (_) => TrainigProvider()), // ChangeNotifierProvider(create: (_) => EducationProvider()), // ChangeNotifierProvider(create: (_) => AwardProvider()), // ChangeNotifierProvider(create: (_) => CertificateProvider()), // ChangeNotifierProvider(create: (_) => NIHGrantsProvider()), // ChangeNotifierProvider(create: (_) => ProcedureProvider()), // //K2 Provider // ChangeNotifierProvider(create: (_) => KolListProvider()), // ChangeNotifierProvider(create: (_) => LocationKolProvider()), // ChangeNotifierProvider(create: (_) => PhonenoProviderK2()), // ChangeNotifierProvider(create: (_) => EmailProviderK2()), // ChangeNotifierProvider(create: (_) => EducationProviderK2()), // ChangeNotifierProvider(create: (_) => TrainigProviderK2()), // ChangeNotifierProvider(create: (_) => AwardProviderK2()), // ChangeNotifierProvider(create: (_) => CertificateProviderK2()), // ChangeNotifierProvider(create: (_) => AffiliationsProviderk2()), // ChangeNotifierProvider(create: (_) => EventProviderK2()), // ChangeNotifierProvider( // create: (_) => HiveDataRepository( // Hive.box('InteractionConfigDataBox'))), // ], // child: // // SafeArea( // // top: true, // // child: // MaterialApp( // theme: ThemeData( // //fontFamily: "SourceSerif", // ), // debugShowCheckedModeBanner: false, // title: 'Dynamic Links Example', // initialRoute: '/', // routes: { // '/': (BuildContext context) => FutureBuilder( // future: SessionManager().isLoggedIn(), // builder: (context, snapshot) { // print("Data_is : $snapshot"); // if (snapshot.connectionState == ConnectionState.waiting) { // return const CircularProgressIndicator(); // } else if (snapshot.hasError) { // return Text('Error: ${snapshot.error}'); // } else { // final isLoggedIn = snapshot.data ?? false; // print("isLoggedIn_is : $isLoggedIn"); // print("secret : $secretkey"); // return isLoggedIn // ? NavigationHomeScreen() // : IntroductionAnimationScreen(); // } // }, // ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), // // '/details': (BuildContext context) => const HomeScreen(), // }, // ), // ), // // ), // ); // }); // } // Future initializeService() async { // final service = FlutterBackgroundService(); // await service.configure( // androidConfiguration: AndroidConfiguration( // // this will be executed when app is in foreground or background in separated isolate // onStart: onStart, // // auto start service // autoStart: true, // isForegroundMode: false, // ), // iosConfiguration: IosConfiguration( // // auto start service // autoStart: true, // // this will be executed when app is in foreground in separated isolate // onForeground: onStart, // // you have to enable background fetch capability on xcode project // onBackground: onIosBackground, // ), // ); // await service.startService(); // } // @pragma('vm:entry-point') // Future onIosBackground(ServiceInstance service) async { // WidgetsFlutterBinding.ensureInitialized(); // DartPluginRegistrant.ensureInitialized(); // SharedPreferences preferences = await SharedPreferences.getInstance(); // await preferences.reload(); // final log = preferences.getStringList('log') ?? []; // log.add(DateTime.now().toIso8601String()); // await preferences.setStringList('log', log); // return true; // } // @pragma('vm:entry-point') // void onStart(ServiceInstance service) async { // print("Background service started"); // if (service is AndroidServiceInstance) { // // callApiInBackground; // service.on('setAsForeground').listen((event) { // service.setAsForegroundService(); // print("Hey Hi i am foground"); // }); // service.on('setAsBackground').listen((event) { // service.setAsBackgroundService(); // print("Hey Hi i am background"); // }); // } // print('NewwwFLUTTER BACKGROUND SERVICE: ${DateTime.now()}'); // service.on('stopService').listen((event) { // service.stopSelf(); // }); // startPeriodicCalls(); // // Timer.periodic(const Duration(seconds: 20), (timer) async { // // print('FLUTTER BACKGROUND SERVICE: ${DateTime.now()}'); // // // final response1 = // // // await http.get(Uri.parse('http://192.168.2.170:8000/all-routes')); // // // if (response1.statusCode == 200) { // // // print('API call successful1 : ${response1.body}'); // // // } else { // // // print('API call failed : ${response1.body}'); // // // } // // startPeriodicCalls(); // // }); // } // Map _timers = {}; // // void startPeriodicCalls() { // // Constants.apiIntervals1.forEach((url, interval) { // // print("URL_iss: ${url}, InterVal_iss: ${interval}"); // // _timers[url] = Timer.periodic(Duration(minutes: interval), (timer) async { // // await fetchApiData(url); // // }); // // }); // // } // startPeriodicCalls() { // print("pooja"); // Constants.apiIntervals1.forEach((key, item) { // print( // "URL_iss: ${item['url']}, InterVal_iss: ${item['intervals']}, HiveName: ${item['hivename']}"); // _timers[item['url']] = // Timer.periodic(Duration(minutes: item['intervals']), (timer) async { // await fetchApiData(item['url'], item['hivename'], item['hivetype']); // }); // }); // } // PostApiCall(url, methodName, sendPostData) async { // try { // final response = await Dio().post( // url, // data: sendPostData, // options: Options( // headers: { // 'Content-Type': 'application/json', // }, // ), // ); // if (response.statusCode == 200) { // debugPrint("Response_is : ${response.data}"); // return response; // } else { // return 'Failed to load data'; // } // } catch (e) { // print('Error fetching data123 from $url: $e'); // } // } // Future fetchApiData(String url, String hivename, String hivetype) async { // print("Post_Url_iss: ${url}, ${hivename} , ${hivetype}"); // var box, postdata; // // var box = Hive.box(hivename); // switch (hivename) { // case 'InteractionDataBox': // box = await Hive.openBox(hivename); // final provider = ViewInteractionProvider(); // final prov = InteractionProvider(); // postdata = await provider.getAllRecordsforIntervalSync(hivename); // postdata.forEach((item) async { // PostApiCall(url, "post", prov.formJson(item)); // }); // break; // default: // box = Hive.box(hivename); // postdata = box.values.toList(); // postdata.forEach((item) async { // PostApiCall(url, "post", item); // }); // break; // } // } import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:ui'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:dio/dio.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:konectar_events/contacts_module/constants.dart'; import 'package:konectar_events/contacts_module/provider_class/affiliationsprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/certificate_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/educationprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/email_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/engagement_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/events_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/hcp%20_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_add_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_aff_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_awards_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_certificate_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_education_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_email_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_event_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_list_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_locationprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_pno_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/k2_provider/kol_training_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/location_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/medicalinsightprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/nih_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/patent_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/phoneno_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/procedureprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/publications_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/single_hcpprovider.dart'; import 'package:konectar_events/contacts_module/provider_class/speaker_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/training_provider.dart'; import 'package:konectar_events/contacts_module/provider_class/trials_provider.dart'; import 'package:konectar_events/contacts_module/service.dart/service.dart'; import 'package:konectar_events/contacts_module/storage_hive/aff_data/aff_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/awa_data/awa_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/cer_hive/cer_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/edu_data/edu_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/email_data/email_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/events_data/event_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/kol_info/kol_info_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/loc_data/location_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/nih_grant_data/nih_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/note_data/note_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/patent_data/patent_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/pno_data/pno_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/procedure_data/pro_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/pub_data/pub_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/speaker_data/speaker_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/traning_data/traning_model_hive.dart'; import 'package:konectar_events/contacts_module/storage_hive/trials_data/trial_model_hive.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/interactionprovider.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/interaction_config_data.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/interaction_data.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/json_form_data.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/save_interaction.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/repository/hive_repository.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/util.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart'; import 'package:konectar_events/firebaseexample.dart'; import 'package:konectar_events/model/hive_api_constants.dart'; import 'package:konectar_events/model/myeventsmodel.dart'; import 'package:konectar_events/model/neweventsmodel.dart'; import 'package:konectar_events/model/sessionnotesmodel.dart'; import 'package:konectar_events/model/userdata_model.dart'; import 'package:konectar_events/utils/apicall.dart'; import 'package:konectar_events/utils/sessionmanager.dart'; import 'package:konectar_events/view/home.dart'; import 'package:konectar_events/view/login.dart'; import 'package:konectar_events/view/login_components/intropaging.dart'; import 'package:konectar_events/view/navigation_home_screen.dart'; import 'package:konectar_events/viewmodel/eventsprovider.dart'; import 'package:konectar_events/viewmodel/hcpprofprovider.dart'; import 'package:konectar_events/viewmodel/loginprovider.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:provider/provider.dart'; import 'package:openid_client/openid_client.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:shared_preferences/shared_preferences.dart'; //import 'openid/openid_io.dart' if (dart.library.html) 'openid_browser.dart'; import 'contacts_module/provider_class/award_provider.dart'; import 'firebase_options.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; late SharedPreferences sp; Future main() async { WidgetsFlutterBinding.ensureInitialized(); // startPeriodicCalls(); sp = await SharedPreferences.getInstance(); await Hive.initFlutter(); await initializeService(); Hive.registerAdapter(UserDataAdapter()); Hive.registerAdapter(EventsListAdapter()); Hive.registerAdapter(SessionNotesModelAdapter()); Hive.registerAdapter(MyEventsModelAdapter()); Hive.registerAdapter(SaveInteractionAdapter()); Hive.registerAdapter(InteractionConfigDataAdapter()); Hive.registerAdapter(InteractionResultDataAdapter()); Hive.registerAdapter(FormFieldDataAdapter()); Hive.registerAdapter(ValidationAdapter()); Hive.registerAdapter(SectionListAdapter()); Hive.registerAdapter(InputClassAdapter()); Hive.registerAdapter(InteractionWidgetAdapter()); // Hive.registerAdapter(UserDataAdapter()); Hive.registerAdapter(SendSaveJsonAdapter()); Hive.registerAdapter(MultipleSectionListAdapter()); Hive.registerAdapter(SaveAdapter()); Hive.registerAdapter(SaveInteractionFormJsonAdapter()); await Hive.openBox('InteractionDataBox'); var boxhive = await Hive.openBox('InteractionConfigDataBox'); var box = await Hive.openBox('mycontact'); var box1 = await Hive.openBox('myfilter'); await Hive.openBox('checkvalue'); await Hive.openBox('hcpdata'); await Hive.openBox('notehive'); // Hive.registerAdapter(NoteAdapter()); Hive.registerAdapter(AffiliationAdapter()); // await Hive.openBox('affiliationshive'); Hive.registerAdapter(KolInfoAdapter()); Hive.registerAdapter(PublicationAdapter()); Hive.registerAdapter(EventsAdapter()); Hive.registerAdapter(TrialsAdapter()); Hive.registerAdapter(LocationAdapter()); Hive.registerAdapter(PhoneNoAdapter()); Hive.registerAdapter(EmailAdapter()); Hive.registerAdapter(EduAdapter()); Hive.registerAdapter(AwaAdapter()); Hive.registerAdapter(CerAdapter()); Hive.registerAdapter(PatentAdapter()); Hive.registerAdapter(NihAdapter()); Hive.registerAdapter(ProAdapter()); Hive.registerAdapter(Training1Adapter()); Hive.registerAdapter(SpeAdapter()); Hive.registerAdapter(HiveApiConstantsAdapter()); // Hive.registerAdapter(NoteAdapter()); await Hive.openBox("UserDataBox"); await Hive.openBox("EventsListBox"); await Hive.openBox("SessionNotesModelBox"); await Hive.openBox("MyEventsBox"); await Hive.openBox("hiveApiConstants"); WidgetsFlutterBinding.ensureInitialized(); usePathUrlStrategy(); SharedPreferences.getInstance().then((instance) { bool isloggedIn = instance.getBool('isloggedin') ?? false; print("checkhere before:$isloggedIn"); String secretkey = instance.getString('secretkey') ?? ""; runApp( MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => LoginProvider()), ChangeNotifierProvider(create: (_) => EventsProvider()), ChangeNotifierProvider(create: (_) => HcpProfileProvider()), //Contacts ChangeNotifierProvider(create: (_) => InteractionProvider()), ChangeNotifierProvider(create: (_) => ViewInteractionProvider()), ChangeNotifierProvider(create: (_) => hcpProvider()), ChangeNotifierProvider(create: (_) => Singlehcpdetails()), ChangeNotifierProvider(create: (_) => AffiliationsProvider()), ChangeNotifierProvider(create: (_) => PublicatioProvider()), ChangeNotifierProvider(create: (_) => EventProvider()), ChangeNotifierProvider(create: (_) => TrialsProvider()), ChangeNotifierProvider(create: (_) => MediacalInsightProvider()), ChangeNotifierProvider(create: (_) => SpekerEvalutionProvider()), ChangeNotifierProvider(create: (_) => EnagagementProvider()), ChangeNotifierProvider(create: (_) => LocationProvider()), ChangeNotifierProvider(create: (_) => PhonenoProvider()), ChangeNotifierProvider(create: (_) => EmailProvider()), ChangeNotifierProvider(create: (_) => PatentProvider()), ChangeNotifierProvider(create: (_) => TrainigProvider()), ChangeNotifierProvider(create: (_) => EducationProvider()), ChangeNotifierProvider(create: (_) => AwardProvider()), ChangeNotifierProvider(create: (_) => CertificateProvider()), ChangeNotifierProvider(create: (_) => NIHGrantsProvider()), ChangeNotifierProvider(create: (_) => ProcedureProvider()), //K2 Provider ChangeNotifierProvider(create: (_) => KolListProvider()), ChangeNotifierProvider(create: (_) => LocationKolProvider()), ChangeNotifierProvider(create: (_) => PhonenoProviderK2()), ChangeNotifierProvider(create: (_) => EmailProviderK2()), ChangeNotifierProvider(create: (_) => EducationProviderK2()), ChangeNotifierProvider(create: (_) => TrainigProviderK2()), ChangeNotifierProvider(create: (_) => AwardProviderK2()), ChangeNotifierProvider(create: (_) => CertificateProviderK2()), ChangeNotifierProvider(create: (_) => AffiliationsProviderk2()), ChangeNotifierProvider(create: (_) => EventProviderK2()), ChangeNotifierProvider(create: (_) => AddNotesProvider()), ChangeNotifierProvider( create: (_) => HiveDataRepository( Hive.box('InteractionConfigDataBox'))), ], child: SafeArea( top: true, child: MaterialApp( theme: ThemeData( //fontFamily: "SourceSerif", ), debugShowCheckedModeBanner: false, title: 'Dynamic Links Example', initialRoute: '/', routes: { '/': (BuildContext context) => FutureBuilder( future: SessionManager().isLoggedIn(), builder: (context, snapshot) { print("Data_is : $snapshot"); if (snapshot.connectionState == ConnectionState.waiting) { return const CircularProgressIndicator(); } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { final isLoggedIn = snapshot.data ?? false; print("isLoggedIn_is : $isLoggedIn"); print("secret : $secretkey"); return isLoggedIn ? NavigationHomeScreen() : IntroductionAnimationScreen(); } }, ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), // '/details': (BuildContext context) => const HomeScreen(), }, ), ), ), ); }); } Future initializeService() async { final service = FlutterBackgroundService(); await service.configure( androidConfiguration: AndroidConfiguration( // this will be executed when app is in foreground or background in separated isolate onStart: onStart, // auto start service autoStart: true, isForegroundMode: false, ), iosConfiguration: IosConfiguration( // auto start service autoStart: true, // this will be executed when app is in foreground in separated isolate onForeground: onStart, // you have to enable background fetch capability on xcode project onBackground: onIosBackground, ), ); await service.startService(); } @pragma('vm:entry-point') Future onIosBackground(ServiceInstance service) async { WidgetsFlutterBinding.ensureInitialized(); DartPluginRegistrant.ensureInitialized(); SharedPreferences preferences = await SharedPreferences.getInstance(); await preferences.reload(); final log = preferences.getStringList('log') ?? []; log.add(DateTime.now().toIso8601String()); await preferences.setStringList('log', log); return true; } @pragma('vm:entry-point') void onStart(ServiceInstance service) async { print("Background service started"); if (service is AndroidServiceInstance) { // callApiInBackground; service.on('setAsForeground').listen((event) { service.setAsForegroundService(); print("Hey Hi i am foground"); }); service.on('setAsBackground').listen((event) { service.setAsBackgroundService(); print("Hey Hi i am background"); }); } print('NewwwFLUTTER BACKGROUND SERVICE: ${DateTime.now()}'); service.on('stopService').listen((event) { service.stopSelf(); }); startPeriodicCalls(); } Map _timers = {}; startPeriodicCalls() { print("pooja"); Constants.apiIntervals1.forEach((key, item) { print( "URL_iss: ${item['url']}, InterVal_iss: ${item['intervals']}, HiveName: ${item['hivename']}"); _timers[item['url']] = Timer.periodic(Duration(minutes: item['intervals']), (timer) async { await fetchApiData(item['url'], item['hivename'], item['hivetype']); }); }); } PostApiCall(url, methodName, sendPostData) async { try { final response = await Dio().post( url, data: sendPostData, options: Options( headers: { 'Content-Type': 'application/json', }, ), ); if (response.statusCode == 200) { debugPrint("Response_is : ${response.data}"); return response; } else { return 'Failed to load data'; } } catch (e) { print('Error fetching data123 from $url: $e'); } } Future fetchApiData(String url, String hivename, String hivetype) async { print("Post_Url_iss: ${url}, ${hivename} , ${hivetype}"); var box, postdata; // var box = Hive.box(hivename); switch (hivename) { case 'InteractionDataBox': box = await Hive.openBox(hivename); final provider = ViewInteractionProvider(); final prov = InteractionProvider(); postdata = await provider.getAllRecordsforIntervalSync(hivename); postdata.forEach((item) async { PostApiCall(url, "post", prov.formJson(item)); }); break; default: box = Hive.box(hivename); postdata = box.values.toList(); print("PostData_isss: $postdata"); postdata.forEach((item) async { PostApiCall(url, "post", item); }); break; } }