import 'dart:async'; import 'dart:convert'; import 'dart:io'; 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/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/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/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: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'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); final dio = Dio(); // await Firebase.initializeApp( // options: DefaultFirebaseOptions.currentPlatform, // ); // final remoteConfig = FirebaseRemoteConfig.instance; // await remoteConfig.setDefaults(const { // "clientstring": "client-A", // }); // await remoteConfig.setConfigSettings(RemoteConfigSettings( // fetchTimeout: const Duration(seconds: 10), // minimumFetchInterval: const Duration(seconds: 20), // )); // await remoteConfig.fetchAndActivate(); // RemoteConfigValue rawData = remoteConfig.getValue("client-A"); // print(rawData); // const jsonString = // '{"text": "foo", "value": 1, "status": false, "extra": null}'; // var map = jsonDecode(rawData.toString()); // String title = await remoteConfig.getString("welcomestring"); //await execute(InternetConnectionChecker()); // Create customized instance which can be registered via dependency injection // final InternetConnectionChecker customInstance = // InternetConnectionChecker.createInstance( // checkTimeout: const Duration(milliseconds: 1), // checkInterval: const Duration(milliseconds: 1), // ); // // Check internet connection with created instance // await execute(customInstance); await Hive.initFlutter(); 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()); await Hive.openBox("UserDataBox"); await Hive.openBox("EventsListBox"); await Hive.openBox("SessionNotesModelBox"); await Hive.openBox("MyEventsBox"); 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) async { //StorageService().sharedPreferencesInstance = instance; bool isloggedIn = instance.getBool('isloggedin') ?? false; 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: (_) => HiveDataRepository( Hive.box('InteractionConfigDataBox'))), ], child: SafeArea( top: true, child: MaterialApp( theme: ThemeData( fontFamily: "OpenSans", ), 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 ? MyApp() : LoginScreen(); } }, ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), // '/details': (BuildContext context) => const HomeScreen(), }, ), ), ), ); }); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark, statusBarBrightness: !kIsWeb && Platform.isAndroid ? Brightness.dark : Brightness.light, systemNavigationBarColor: Colors.white, systemNavigationBarDividerColor: Colors.transparent, systemNavigationBarIconBrightness: Brightness.dark, )); return MaterialApp( title: 'Flutter UI', debugShowCheckedModeBanner: false, // theme: ThemeData( // primarySwatch: Colors.blue, // textTheme: AppTheme.textTheme, // platform: TargetPlatform.iOS, // ), home: NavigationHomeScreen(), ); } }