init static method
Initialize Nylo
Implementation
static Future<Nylo> init(
{Function? setup,
Function(Nylo nylo)? setupFinished,
bool? showSplashScreen}) async {
const String envFile = String.fromEnvironment(
'ENV_FILE',
defaultValue: '.env',
);
await dotenv.load(
fileName: envFile,
mergeWith: showSplashScreen != null
? {"SHOW_SPLASH_SCREEN": 'true'}
: const {});
Intl.defaultLocale = getEnv('DEFAULT_LOCALE', defaultValue: 'en');
await _configureLocalTimeZone();
Nylo nyloApp = Nylo();
if (setup == null) {
nyloApp._cache = await NyCache.getInstance();
if (setupFinished != null) {
await setupFinished(nyloApp);
}
if (nyloApp._enableErrorStack == true) {
await ErrorStack.init(
level: nyloApp._errorStackLogLevel ?? ErrorStackLogLevel.verbose,
initialRoute: nyloApp.getInitialRoute(),
errorWidget: nyloApp._errorStackErrorWidget);
}
if (nyloApp._useLocalNotifications == true) {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
if (nyloApp._initializationSettings != null) {
nyloApp.setLocalNotifications(flutterLocalNotificationsPlugin);
}
}
return nyloApp;
}
nyloApp = await setup();
nyloApp._cache = await NyCache.getInstance();
if (setupFinished != null) {
await setupFinished(nyloApp);
}
if (nyloApp._enableErrorStack == true) {
await ErrorStack.init(
level: nyloApp._errorStackLogLevel ?? ErrorStackLogLevel.verbose,
initialRoute: nyloApp.getInitialRoute(),
errorWidget: nyloApp._errorStackErrorWidget);
}
if (nyloApp._useLocalNotifications == true) {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
if (nyloApp._initializationSettings != null) {
nyloApp.setLocalNotifications(flutterLocalNotificationsPlugin);
}
}
return nyloApp;
}