main function
Implementation
Future<void> main() async {
if (!isDev && kDebugMode) {
debugPrint(
'\x1B[31m'
'\nWARNING: This is not a proper development build.\n'
"The '--flavor dev' flag is no longer sufficient to run the app in development mode.\n"
'To correctly run the app in dev mode, run "flutter run --flavor dev --dart-define=IS_DEV=true".\n'
'For more information, see https://github.com/WesselvanDam/ProjectALA/pull/841 \n'
'\x1B[0m',
);
}
setPathUrlStrategy();
GoRouter.optionURLReflectsImperativeAPIs = true;
WidgetsFlutterBinding.ensureInitialized();
FlutterError.demangleStackTrace = (StackTrace stack) {
// Trace and Chain are classes in package:stack_trace
switch (stack.runtimeType) {
case Trace _:
return (stack as Trace).vmTrace;
case Chain _:
return (stack as Chain).toTrace().vmTrace;
default:
return stack;
}
};
ErrorWidget.builder = (details) {
if (kDebugMode) {
return SingleChildScrollView(child: ErrorWidget(details));
}
return Container(
alignment: Alignment.center,
color: const Color(0xff006600),
padding: const EdgeInsets.all(8),
child: Text(
'${t.error.unknown} ${t.error.dev}\n\n${details.exception}\n\n${details.stack}',
),
);
};
final prefs = await SharedPreferences.getInstance();
final localePreference = prefs.getString('locale');
pluralResolver();
localePreference == null
? LocaleSettings.useDeviceLocale()
: LocaleSettings.setLocale(
localePreference == 'nl' ? AppLocale.nl : AppLocale.en,
);
flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveBackgroundNotificationResponse:
nonTerminatedNotificationHandler,
onDidReceiveNotificationResponse: nonTerminatedNotificationHandler,
);
GoogleFonts.config.allowRuntimeFetching = false;
await Firebase.initializeApp(
options: !kIsWeb
? null
: isDev
? const FirebaseOptions(
apiKey: 'AIzaSyAc6enbDgaDz6uCiZlxzND1xaiM9yREYno',
appId: '1:741466012033:web:0c3f7c4ffac01b2bda5080',
messagingSenderId: '741466012033',
projectId: 'aegee-leiden-app-dev',
authDomain: 'aegee-leiden-app-dev.firebaseapp.com',
storageBucket: 'aegee-leiden-app-dev.appspot.com',
)
: const FirebaseOptions(
apiKey: 'AIzaSyD14d5C59S7ExX8cfk5lBYbv6DB4hZdiQA',
appId: '1:659197960555:web:146720059e4209866b2c2e',
messagingSenderId: '659197960555',
projectId: 'aegee-leiden-app',
authDomain: 'aegee-leiden-app.firebaseapp.com',
databaseURL: 'https://aegee-leiden-app.firebaseio.com',
storageBucket: 'aegee-leiden-app.appspot.com',
measurementId: 'G-PCV7JQ9JKP',
),
);
runApp(
ProviderScope(
observers: [
if (isDev)
RiverpodProviderObserver(),
],
overrides: [
sharedPreferencesProvider.overrideWithValue(prefs),
],
child: TranslationProvider(child: const MyApp()),
),
);
}