init method
Implementation
Future init({AppConfig? config}) async {
_appConfig = config;
try {
var appTheme = await ShareUtils.getInt(appThemeMode);
if (appTheme != null) currentThemeMode = ThemeMode.values[appTheme];
} catch (e) {
print('$e');
}
try {
await EasyLocalization.ensureInitialized();
} catch (e) {
print('$e');
}
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
try {
EasyLoading.instance.maskType = EasyLoadingMaskType.black;
if (_appConfig?.supaUrl?.isNotEmpty == true &&
_appConfig?.supaAnonKey?.isNotEmpty == true) {
try {
await Supabase.initialize(
url: _appConfig?.supaUrl ?? '',
anonKey: _appConfig?.supaAnonKey ?? '',
);
} catch (e) {
print('$e');
}
supabase = Supabase.instance.client;
user = supabase.auth.currentUser;
authSub = supabase.auth.onAuthStateChange.listen((event) {
user = event.session?.user;
// countAction();
if (hasListeners) notifyListeners();
// if (event.event == AuthChangeEvent.signedIn) {
// config?.accountChange?.call(event);
// } else if (event.event == AuthChangeEvent.signedOut) {}
config?.accountChange?.call(event);
});
}
} catch (e) {
print('$e');
}
}