UEMonitoredApp constructor

UEMonitoredApp({
  1. Key? key,
  2. GlobalKey<NavigatorState>? navigatorKey,
  3. GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey,
  4. Widget? home,
  5. Map<String, WidgetBuilder> routes = const <String, WidgetBuilder>{},
  6. String? initialRoute,
  7. RouteFactory? onGenerateRoute,
  8. InitialRouteListFactory? onGenerateInitialRoutes,
  9. RouteFactory? onUnknownRoute,
  10. List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[],
  11. TransitionBuilder? builder,
  12. String? title = '',
  13. GenerateAppTitle? onGenerateTitle,
  14. Color? color,
  15. ThemeData? theme,
  16. ThemeData? darkTheme,
  17. ThemeData? highContrastTheme,
  18. ThemeData? highContrastDarkTheme,
  19. ThemeMode themeMode = ThemeMode.system,
  20. Duration themeAnimationDuration = kThemeAnimationDuration,
  21. Curve themeAnimationCurve = Curves.linear,
  22. Locale? locale,
  23. Iterable<LocalizationsDelegate>? localizationsDelegates,
  24. LocaleListResolutionCallback? localeListResolutionCallback,
  25. LocaleResolutionCallback? localeResolutionCallback,
  26. Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')],
  27. bool debugShowMaterialGrid = false,
  28. bool showPerformanceOverlay = false,
  29. bool checkerboardRasterCacheImages = false,
  30. bool checkerboardOffscreenLayers = false,
  31. bool showSemanticsDebugger = false,
  32. bool debugShowCheckedModeBanner = true,
  33. Map<LogicalKeySet, Intent>? shortcuts,
  34. Map<Type, Action<Intent>>? actions,
  35. String? restorationScopeId,
  36. ScrollBehavior? scrollBehavior,
  37. bool useInheritedMediaQuery = false,
})

Creates a Monitored MaterialApp.

At least one of home, routes, onGenerateRoute, or builder must be non-null. If only routes is given, it must include an entry for the Navigator.defaultRouteName (/), since that is the route used when the application is launched with an intent that specifies an otherwise unsupported route.

This class creates an instance of WidgetsApp.

Implementation

UEMonitoredApp(
    {super.key,
    super.navigatorKey,
    super.scaffoldMessengerKey,
    super.home,
    super.routes,
    String? initialRoute,
    RouteFactory? onGenerateRoute,
    InitialRouteListFactory? onGenerateInitialRoutes,
    RouteFactory? onUnknownRoute,
    List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[],
    super.builder,
    super.title,
    super.onGenerateTitle,
    super.color,
    super.theme,
    super.darkTheme,
    super.highContrastTheme,
    super.highContrastDarkTheme,
    ThemeMode super.themeMode,
    super.themeAnimationDuration,
    super.themeAnimationCurve,
    super.locale,
    super.localizationsDelegates,
    super.localeListResolutionCallback,
    super.localeResolutionCallback,
    super.supportedLocales,
    super.debugShowMaterialGrid,
    super.showPerformanceOverlay,
    super.checkerboardRasterCacheImages,
    super.checkerboardOffscreenLayers,
    super.showSemanticsDebugger,
    super.debugShowCheckedModeBanner,
    Map<LogicalKeySet, Intent>? super.shortcuts,
    super.actions,
    super.restorationScopeId,
    super.scrollBehavior,
    bool useInheritedMediaQuery = false})
    : super(
        initialRoute: () {
          _onPreNavigation();
          return initialRoute;
        }(),
        onGenerateRoute: (RouteSettings settings) {
          // Pre-navigation action
          _onPreNavigation();
          // Call the developer's onGenerateRoute if provided
          if (onGenerateRoute != null) {
            return onGenerateRoute(settings);
          }
          // Default route handling
          return null;
        },
        onGenerateInitialRoutes: onGenerateInitialRoutes != null
            ? (initialRoute) {
                _onPreNavigation();
                return onGenerateInitialRoutes(initialRoute);
              }
            : null,
        onUnknownRoute: onUnknownRoute != null
            ? (RouteSettings settings) {
                _onPreNavigation();
                return onUnknownRoute(settings);
              }
            : null,
        navigatorObservers: [
          _UENavigationObserver(),
          ...navigatorObservers,
        ],
      );