Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

app.dart

petrovWF edited this page Jun 16, 2021 · 4 revisions

App is stateful widget which configures the MaterialApp. Before calling the build method pre app configuration is executed, also after the build method post app configuration will be executed. For more information about pre and post app configurations please check:

initState

  • Activates AppLifecycleObserver
  • Initializes AppRouterDelegate
  • Initializes LocalizationNotifier

didChangeDependencies

When build method finishes:

  • Calls post app configuration (except in production)
  • Adds ‘debugOverlay’ (except in production)

build

  • Sets preferred orientations
  • Return multi provider with the following providers:
    • ThemeChangeNotifier
    • LocalizationNotifier
    • AppRouterDelegate

Consumer2 will be the child of the MultiProvider and provides observers for:

  • LocalizationNotifier: localeObject which provides locale changes on the fly
  • ThemeChangeNotifier: themeObject which provides theme changes on the fly

MaterialApp is returned from Consumer2 with the following configuration:

  • theme: themeLight()
  • darkTheme: themeDark()
  • themeMode: themeObject.getThemeMode
  • localizationDelegates:
    • AppLocalizations delegate
    • GlobalMaterialLocalizations delegate
    • GlobalWidgetsLocalizations delegate
    • GlobalCupertinoLocalizations delegate
  • locale: localeObject.locale
  • supportedLocales: [EN, MK]
  • home: Router instance with:
    • routerDelegate: _appRouterDelegate
    • backButtonDispatcher: RootBackButtonDispatcher instance

dispose

  • Deactivates AppLifecycleObserver
Clone this wiki locally