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

app.dart

Dimitar Zabaznoski edited this page Jun 16, 2021 · 4 revisions

App is the entry widget of the app. It's a stateful widget that builds MaterialApp.

Before the build method, the pre-app configuration is executed, also after the build method, the post-app configuration will be executed. For more information about pre and post app configurations please check the configuration docs.

App widget lifecycle

initState

  • Activates AppLifecycleObserver
  • Initializes AppRouterDelegate
  • Initializes LocalizationNotifier

didChangeDependencies

When the build method finishes:

  • Calls post app configuration
  • 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 and MK
  • home: Router instance with:
    • routerDelegate: _appRouterDelegate
    • backButtonDispatcher: RootBackButtonDispatcher instance

dispose

  • Deactivates AppLifecycleObserver
Clone this wiki locally