materialApp static method
Widget
materialApp({
- Key? key,
- String? initialRoute,
- Route? onGenerateRoute(
- RouteSettings settings
- Route? onUnknownRoute(
- RouteSettings settings
- 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 builder()?,
- Locale? localeResolutionCallback()?,
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,
),
);
}