materialApp static method

Widget materialApp({
  1. Key? key,
  2. GlobalKey<NavigatorState>? navigatorKey,
  3. String? initialRoute,
  4. Route? onGenerateRoute(
    1. RouteSettings settings
    )?,
  5. Route? onUnknownRoute(
    1. RouteSettings settings
    )?,
  6. List<NavigatorObserver> navigatorObservers = const [],
  7. List<Locale> supportedLocales = const [Locale('en', 'US')],
  8. ThemeMode themeMode = ThemeMode.system,
  9. bool debugShowCheckedModeBanner = false,
  10. bool debugShowMaterialGrid = false,
  11. bool showPerformanceOverlay = false,
  12. bool checkerboardRasterCacheImages = false,
  13. bool checkerboardOffscreenLayers = false,
  14. bool showSemanticsDebugger = false,
  15. Duration themeDuration = const Duration(milliseconds: 200),
  16. Curve themeCurve = Curves.easeInOut,
  17. Color? backgroundColor,
  18. Widget? home,
  19. String? title,
  20. Widget builder(
    1. BuildContext,
    2. Widget?
    )?,
  21. Locale? localeResolutionCallback(
    1. Locale?,
    2. Iterable<Locale>
    )?,
})

Factory constructor for a complete MaterialApp setup.

This provides a fully configured MaterialApp with theme and localization support out of the box.

Implementation

static Widget materialApp({
  Key? key,
  GlobalKey<NavigatorState>? navigatorKey,
  String? initialRoute,
  Route<dynamic>? Function(RouteSettings settings)? onGenerateRoute,
  Route<dynamic>? Function(RouteSettings settings)? onUnknownRoute,
  List<NavigatorObserver> navigatorObservers = const [],
  List<Locale> supportedLocales = const [Locale('en', 'US')],
  ThemeMode themeMode = ThemeMode.system,
  bool debugShowCheckedModeBanner = false,
  bool debugShowMaterialGrid = false,
  bool showPerformanceOverlay = false,
  bool checkerboardRasterCacheImages = false,
  bool checkerboardOffscreenLayers = false,
  bool showSemanticsDebugger = false,
  Duration themeDuration = const Duration(milliseconds: 200),
  Curve themeCurve = Curves.easeInOut,
  Color? backgroundColor,
  Widget? home,
  String? title,
  Widget Function(BuildContext, Widget?)? builder,
  Locale? Function(Locale?, Iterable<Locale>)? localeResolutionCallback,
}) {
  return NyApp(
    key: key,
    themeDuration: themeDuration,
    themeCurve: themeCurve,
    backgroundColor: backgroundColor,
    child: (themeData, locale) => MaterialApp(
      navigatorKey: navigatorKey,
      themeMode: themeMode,
      navigatorObservers: navigatorObservers,
      debugShowMaterialGrid: debugShowMaterialGrid,
      showPerformanceOverlay: showPerformanceOverlay,
      checkerboardRasterCacheImages: checkerboardRasterCacheImages,
      checkerboardOffscreenLayers: checkerboardOffscreenLayers,
      showSemanticsDebugger: showSemanticsDebugger,
      debugShowCheckedModeBanner: debugShowCheckedModeBanner,
      darkTheme: NyThemeManager.instance.darkTheme?.themeData,
      initialRoute: initialRoute,
      onGenerateRoute: onGenerateRoute,
      onUnknownRoute: onUnknownRoute,
      theme: themeData,
      home: home,
      title: title ?? '',
      builder: builder,
      localeResolutionCallback:
          localeResolutionCallback ??
          (Locale? locale, Iterable<Locale> supportedLocales) => locale,
      localizationsDelegates: NyLocalization.instance.delegates,
      locale: locale,
      supportedLocales: supportedLocales,
    ),
  );
}