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/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 '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()); 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()), ], 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(), ); } }