main function
Implementation
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/// Initialize shared preferences for LG connection
await LgConnectionSharedPref.init();
await PromptsSharedPref.init();
await SettingsSharedPref.init();
await FavoritesSharedPref.init();
await APIKeySharedPref.init();
Locale locale = await SettingsSharedPref.getLocale();
//clear:
// await FavoritesSharedPref().clearToursList();
// await PromptsSharedPref.clearPreferences();
await dotenv.load(fileName: ".env");
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => Connectionprovider()),
ChangeNotifierProvider(create: (_) => SSHprovider()),
ChangeNotifierProvider(create: (_) => CurrentViewProvider()),
ChangeNotifierProvider(create: (_) => MapTypeProvider()),
ChangeNotifierProvider(create: (_) => ModelErrorProvider()),
ChangeNotifierProvider(create: (_) => GoogleMapProvider()),
ChangeNotifierProvider(create: (_) => DropdownState()),
ChangeNotifierProvider(create: (_) => SearchProvider()),
ChangeNotifierProvider(create: (_) => ColorProvider()),
ChangeNotifierProvider(create: (_) => FontsProvider()),
ChangeNotifierProvider(create: (_) => DisplayedListProvider()),
ChangeNotifierProvider(create: (_) => TourStatusprovider()),
],
child: Phoenix(child: AITouristicInfo(locale: locale)),
),
);
Timer.periodic(const Duration(seconds: 10), (timer) async {
final sshData =
Provider.of<SSHprovider>(navigatorKey.currentContext!, listen: false);
Connectionprovider connection = Provider.of<Connectionprovider>(
navigatorKey.currentContext!,
listen: false);
String? result = await sshData.reconnectClient(
SSHModel(
username: LgConnectionSharedPref.getUserName() ?? '',
host: LgConnectionSharedPref.getIP() ?? '',
passwordOrKey: LgConnectionSharedPref.getPassword() ?? '',
port: int.parse(LgConnectionSharedPref.getPort() ?? '22'),
),
navigatorKey.currentContext!);
if (result == '') {
connection.isLgConnected = true;
} else {
connection.isLgConnected = false;
}
});
}