buildIn method
Override to impose your own WidgetsApp (like CupertinoApp or MaterialApp)
Implementation
@override
Widget buildIn(BuildContext context) {
//
Widget app;
assert(() {
/// Highlights UI while debugging.
debug.debugPaintSizeEnabled = debugPaintSizeEnabled ?? false;
debug.debugPaintBaselinesEnabled = debugPaintBaselinesEnabled ?? false;
debug.debugPaintPointersEnabled = debugPaintPointersEnabled ?? false;
debug.debugPaintLayerBordersEnabled =
debugPaintLayerBordersEnabled ?? false;
debug.debugRepaintRainbowEnabled = debugRepaintRainbowEnabled ?? false;
debug.debugRepaintTextRainbowEnabled =
debugRepaintTextRainbowEnabled ?? false;
return true;
}());
final _routerDelegate = routerDelegate ?? onRouterDelegate();
final _routerConfig = routerConfig ?? onRouterConfig();
var _routeInformationParser =
routeInformationParser ?? onRouteInformationParser();
// Supply the appropriate parser for the developer.
if (_routerDelegate is v.AppRouterDelegate &&
_routeInformationParser == null) {
_routeInformationParser = v.AppRouteInformationParser();
}
if (useCupertino!) {
// A CupertinoApp object has been supplied.
if (cupertinoApp != null) {
app = cupertinoApp!;
//
} else if (_routerDelegate == null && _routerConfig == null) {
//
app = CupertinoApp(
key: key ?? cupertinoKey,
navigatorKey: navigatorKey ?? onNavigatorKey(),
routes: routes ?? onRoutes() ?? const <String, WidgetBuilder>{},
initialRoute: initialRoute ?? onInitialRoute(),
onGenerateRoute: onGenerateRoute ?? onOnGenerateRoute(),
onUnknownRoute: onUnknownRoute ?? onOnUnknownRoute(),
navigatorObservers: _navigatorObservers(),
builder: builder ?? onBuilder(),
title: title = onTitle(), // Important to assign an empty string
onGenerateTitle: onGenerateTitle ?? onOnGenerateTitle(context),
color: color ?? onColor() ?? Colors.blue,
theme: _iosThemeData(),
locale:
onLocale() ?? locale, // locale gets assigned elsewhere so switch
localizationsDelegates:
localizationsDelegates ?? onLocalizationsDelegates(),
localeListResolutionCallback:
localeListResolutionCallback ?? onLocaleListResolutionCallback,
localeResolutionCallback:
localeResolutionCallback ?? onLocaleResolutionCallback,
supportedLocales: v.App.supportedLocales = supportedLocales ??
onSupportedLocales() ??
const <Locale>[Locale('en', 'US')],
showPerformanceOverlay:
showPerformanceOverlay ?? onShowPerformanceOverlay() ?? false,
checkerboardRasterCacheImages: checkerboardRasterCacheImages ??
onCheckerboardRasterCacheImages() ??
false,
checkerboardOffscreenLayers: checkerboardOffscreenLayers ??
onCheckerboardOffscreenLayers() ??
false,
showSemanticsDebugger:
showSemanticsDebugger ?? onShowSemanticsDebugger() ?? false,
debugShowCheckedModeBanner: debugShowCheckedModeBanner ??
onDebugShowCheckedModeBanner() ??
false,
shortcuts: shortcuts ?? onShortcuts(),
actions: actions ?? onActions(),
restorationScopeId: restorationScopeId ?? onRestorationScopeId(),
scrollBehavior: scrollBehavior ?? onScrollBehavior(),
useInheritedMediaQuery:
useInheritedMediaQuery ?? onInheritedMediaQuery() ?? false,
// Let the parameters run before the home parameter.
home: home ?? onHome(),
);
} else {
//
app = CupertinoApp.router(
key: key ?? cupertinoKey,
routeInformationProvider:
routeInformationProvider ?? onRouteInformationProvider(),
routeInformationParser: _routeInformationParser,
routerDelegate: _routerDelegate,
routerConfig: _routerConfig,
theme: _iosThemeData(),
builder: builder ?? onBuilder(),
title: title = onTitle(),
onGenerateTitle: onGenerateTitle ?? onOnGenerateTitle(context),
color: color ?? onColor() ?? Colors.blue,
locale:
onLocale() ?? locale, // locale gets assigned elsewhere so switch
localizationsDelegates:
localizationsDelegates ?? onLocalizationsDelegates(),
localeListResolutionCallback:
localeListResolutionCallback ?? onLocaleListResolutionCallback,
localeResolutionCallback:
localeResolutionCallback ?? onLocaleResolutionCallback,
supportedLocales: v.App.supportedLocales = supportedLocales ??
onSupportedLocales() ??
const <Locale>[Locale('en', 'US')],
showPerformanceOverlay:
showPerformanceOverlay ?? onShowPerformanceOverlay() ?? false,
checkerboardRasterCacheImages: checkerboardRasterCacheImages ??
onCheckerboardRasterCacheImages() ??
false,
checkerboardOffscreenLayers: checkerboardOffscreenLayers ??
onCheckerboardOffscreenLayers() ??
false,
showSemanticsDebugger:
showSemanticsDebugger ?? onShowSemanticsDebugger() ?? false,
debugShowCheckedModeBanner: debugShowCheckedModeBanner ??
onDebugShowCheckedModeBanner() ??
false,
shortcuts: shortcuts ?? onShortcuts(),
actions: actions ?? onActions(),
restorationScopeId: restorationScopeId ?? onRestorationScopeId(),
scrollBehavior: scrollBehavior ?? onScrollBehavior(),
useInheritedMediaQuery:
useInheritedMediaQuery ?? onInheritedMediaQuery() ?? false,
);
}
} else {
// A MaterialApp object has been supplied.
if (materialApp != null) {
app = materialApp!;
//
} else if (_routerDelegate == null && _routerConfig == null) {
//
app = MaterialApp(
key: key ?? materialKey,
navigatorKey: navigatorKey ?? onNavigatorKey(),
scaffoldMessengerKey:
scaffoldMessengerKey ?? onScaffoldMessengerKey(),
routes: routes ?? onRoutes() ?? const <String, WidgetBuilder>{},
initialRoute: initialRoute ?? onInitialRoute(),
onGenerateRoute: onGenerateRoute ?? onOnGenerateRoute(),
onUnknownRoute: onUnknownRoute ?? onOnUnknownRoute(),
navigatorObservers: _navigatorObservers(),
builder: builder ?? onBuilder(),
title: title = onTitle(),
onGenerateTitle: onGenerateTitle ?? onOnGenerateTitle(context),
color: color ?? onColor() ?? Colors.white,
theme: _themeData(),
darkTheme: darkTheme ?? onDarkTheme(),
themeMode: themeMode ?? onThemeMode() ?? ThemeMode.system,
locale:
onLocale() ?? locale, // locale gets assigned elsewhere so switch
localizationsDelegates: onLocalizationsDelegates(),
localeListResolutionCallback:
localeListResolutionCallback ?? onLocaleListResolutionCallback,
localeResolutionCallback:
localeResolutionCallback ?? onLocaleResolutionCallback,
supportedLocales: v.App.supportedLocales = supportedLocales ??
onSupportedLocales() ??
const <Locale>[Locale('en', 'US')],
debugShowMaterialGrid:
debugShowMaterialGrid ?? onDebugShowMaterialGrid() ?? false,
showPerformanceOverlay:
showPerformanceOverlay ?? onShowPerformanceOverlay() ?? false,
checkerboardRasterCacheImages: checkerboardRasterCacheImages ??
onCheckerboardRasterCacheImages() ??
false,
checkerboardOffscreenLayers: checkerboardOffscreenLayers ??
onCheckerboardOffscreenLayers() ??
false,
showSemanticsDebugger:
showSemanticsDebugger ?? onShowSemanticsDebugger() ?? false,
debugShowCheckedModeBanner: debugShowCheckedModeBanner ??
onDebugShowCheckedModeBanner() ??
false,
shortcuts: shortcuts ?? onShortcuts(),
actions: actions ?? onActions(),
restorationScopeId: restorationScopeId ?? onRestorationScopeId(),
scrollBehavior: scrollBehavior ?? onScrollBehavior(),
useInheritedMediaQuery:
useInheritedMediaQuery ?? onInheritedMediaQuery() ?? false,
// Let the parameters run before the home parameter.
home: home ?? onHome(),
);
} else {
//
app = MaterialApp.router(
key: key ?? materialKey,
scaffoldMessengerKey:
scaffoldMessengerKey ?? onScaffoldMessengerKey(),
routeInformationProvider:
routeInformationProvider ?? onRouteInformationProvider(),
routeInformationParser: _routeInformationParser,
routerDelegate: _routerDelegate,
routerConfig: _routerConfig,
backButtonDispatcher:
backButtonDispatcher ?? onBackButtonDispatcher(),
builder: builder ?? onBuilder(),
title: title = onTitle(),
onGenerateTitle: onGenerateTitle ?? onOnGenerateTitle(context),
color: color ?? onColor() ?? Colors.white,
theme: _themeData(),
darkTheme: darkTheme ?? onDarkTheme(),
themeMode: themeMode ?? onThemeMode() ?? ThemeMode.system,
locale:
onLocale() ?? locale, // locale gets assigned elsewhere so switch
localizationsDelegates: onLocalizationsDelegates(),
localeListResolutionCallback:
localeListResolutionCallback ?? onLocaleListResolutionCallback,
localeResolutionCallback:
localeResolutionCallback ?? onLocaleResolutionCallback,
supportedLocales: v.App.supportedLocales = supportedLocales ??
onSupportedLocales() ??
const <Locale>[Locale('en', 'US')],
debugShowMaterialGrid:
debugShowMaterialGrid ?? onDebugShowMaterialGrid() ?? false,
showPerformanceOverlay:
showPerformanceOverlay ?? onShowPerformanceOverlay() ?? false,
checkerboardRasterCacheImages: checkerboardRasterCacheImages ??
onCheckerboardRasterCacheImages() ??
false,
checkerboardOffscreenLayers: checkerboardOffscreenLayers ??
onCheckerboardOffscreenLayers() ??
false,
showSemanticsDebugger:
showSemanticsDebugger ?? onShowSemanticsDebugger() ?? false,
debugShowCheckedModeBanner: debugShowCheckedModeBanner ??
onDebugShowCheckedModeBanner() ??
false,
shortcuts: shortcuts ?? onShortcuts(),
actions: actions ?? onActions(),
restorationScopeId: restorationScopeId ?? onRestorationScopeId(),
scrollBehavior: scrollBehavior ?? onScrollBehavior(),
useInheritedMediaQuery:
useInheritedMediaQuery ?? onInheritedMediaQuery() ?? false,
);
}
}
// // The theme may not have been set. This property must have a value.
// // Assign Flutter's current theme default
// // v.App.themeData ??= ThemeData.light();
// if (v.App.themeData == null) {
// v.App.themeData = ThemeData.light();
// // If a color is already stored in preferences, don't overwrite.
// v.App.preferredTheme(
// color: v.App.themeData!.primaryColor, overWrite: false);
// }
//
// // Supply the iOS theme if necessary.
// v.App.iOSTheme ??=
// MaterialBasedCupertinoThemeData(materialTheme: v.App.themeData!);
return app;
}