WidgetsApp class Null safety
A convenience widget that wraps a number of widgets that are commonly required for an application.
One of the primary roles that WidgetsApp provides is binding the system back button to popping the Navigator or quitting the application.
It is used by both MaterialApp and CupertinoApp to implement base functionality for an app.
Builds a MediaQuery using MediaQuery.fromWindow. To use an inherited MediaQuery instead, set useInheritedMediaQuery to true.
Find references to many of the widgets that WidgetsApp wraps in the "See also" section.
See also:
- CheckedModeBanner, which displays a Banner saying "DEBUG" when running in debug mode.
- DefaultTextStyle, the text style to apply to descendant Text widgets without an explicit style.
- MediaQuery, which establishes a subtree in which media queries resolve to a MediaQueryData.
- MediaQuery.fromWindow, which builds a MediaQuery with data derived from WidgetsBinding.window.
- Localizations, which defines the Locale for its
child
. - Title, a widget that describes this app in the operating system.
- Navigator, a widget that manages a set of child widgets with a stack discipline.
- Overlay, a widget that manages a Stack of entries that can be managed independently.
- SemanticsDebugger, a widget that visualizes the semantics for the child.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- WidgetsApp
Constructors
-
WidgetsApp({Key? key, RouteFactory? onGenerateRoute, InitialRouteListFactory? onGenerateInitialRoutes, RouteFactory? onUnknownRoute, String? initialRoute, PageRouteFactory? pageRouteBuilder, Widget? home, Map<
String, WidgetBuilder> routes = const <String, WidgetBuilder>{}, TransitionBuilder? builder, String title = '', GenerateAppTitle? onGenerateTitle, TextStyle? textStyle, required Color color, Locale? locale, Iterable<LocalizationsDelegate> ? localizationsDelegates, LocaleListResolutionCallback? localeListResolutionCallback, LocaleResolutionCallback? localeResolutionCallback, Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')], bool showPerformanceOverlay = false, bool checkerboardRasterCacheImages = false, bool checkerboardOffscreenLayers = false, bool showSemanticsDebugger = false, bool debugShowWidgetInspector = false, bool debugShowCheckedModeBanner = true, InspectorSelectButtonBuilder? inspectorSelectButtonBuilder, Map<ShortcutActivator, Intent> ? shortcuts, Map<Type, Action< ? actions, String? restorationScopeId, bool useInheritedMediaQuery = false})Intent> > - Creates a widget that wraps a number of widgets that are commonly required for an application.
-
WidgetsApp.router({Key? key, RouteInformationProvider? routeInformationProvider, RouteInformationParser<
Object> ? routeInformationParser, RouterDelegate<Object> ? routerDelegate, RouterConfig<Object> ? routerConfig, BackButtonDispatcher? backButtonDispatcher, TransitionBuilder? builder, String title = '', GenerateAppTitle? onGenerateTitle, TextStyle? textStyle, required Color color, Locale? locale, Iterable<LocalizationsDelegate> ? localizationsDelegates, LocaleListResolutionCallback? localeListResolutionCallback, LocaleResolutionCallback? localeResolutionCallback, Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')], bool showPerformanceOverlay = false, bool checkerboardRasterCacheImages = false, bool checkerboardOffscreenLayers = false, bool showSemanticsDebugger = false, bool debugShowWidgetInspector = false, bool debugShowCheckedModeBanner = true, InspectorSelectButtonBuilder? inspectorSelectButtonBuilder, Map<ShortcutActivator, Intent> ? shortcuts, Map<Type, Action< ? actions, String? restorationScopeId, bool useInheritedMediaQuery = false})Intent> > - Creates a WidgetsApp that uses the Router instead of a Navigator.
Properties
-
actions
→ Map<
Type, Action< ?Intent> > -
The default map of intent keys to actions for the application.
final
- backButtonDispatcher → BackButtonDispatcher?
-
A delegate that decide whether to handle the Android back button intent.
final
- builder → TransitionBuilder?
-
A builder for inserting widgets above the Navigator or - when the
WidgetsApp.router constructor is used - above the Router but below the
other widgets created by the WidgetsApp widget, or for replacing the
Navigator/Router entirely.
final
- checkerboardOffscreenLayers → bool
-
Checkerboards layers rendered to offscreen bitmaps.
final
- checkerboardRasterCacheImages → bool
-
Checkerboards raster cache images.
final
- color → Color
-
The primary color to use for the application in the operating system
interface.
final
- debugShowCheckedModeBanner → bool
-
Turns on a little "DEBUG" banner in debug mode to indicate
that the app is in debug mode. This is on by default (in
debug mode), to turn it off, set the constructor argument to
false. In release mode this has no effect.
final
- debugShowWidgetInspector → bool
-
Turns on an overlay that enables inspecting the widget tree.
final
- hashCode → int
- The hash code for this object.
- home → Widget?
-
The widget for the default route of the app (Navigator.defaultRouteName,
which is
/
).final - initialRoute → String?
-
The name of the first route to show, if a Navigator is built.
final
- inspectorSelectButtonBuilder → InspectorSelectButtonBuilder?
-
Builds the widget the WidgetInspector uses to switch between view and
inspect modes.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locale → Locale?
-
The initial locale for this app's Localizations widget is based
on this value.
final
- localeListResolutionCallback → LocaleListResolutionCallback?
-
This callback is responsible for choosing the app's locale
when the app is started, and when the user changes the
device's locale.
final
- localeResolutionCallback → LocaleResolutionCallback?
-
This callback is responsible for choosing the app's locale
when the app is started, and when the user changes the
device's locale.
final
-
localizationsDelegates
→ Iterable<
LocalizationsDelegate> ? -
The delegates for this app's Localizations widget.
final
-
A key to use when building the Navigator.
final
-
The list of observers for the Navigator created for this app.
final
- onGenerateInitialRoutes → InitialRouteListFactory?
-
The routes generator callback used for generating initial routes if
initialRoute is provided.
final
- onGenerateRoute → RouteFactory?
-
The route generator callback used when the app is navigated to a
named route.
final
- onGenerateTitle → GenerateAppTitle?
-
If non-null this callback function is called to produce the app's
title string, otherwise title is used.
final
- onUnknownRoute → RouteFactory?
-
Called when onGenerateRoute fails to generate a route, except for the
initialRoute.
final
- pageRouteBuilder → PageRouteFactory?
-
The PageRoute generator callback used when the app is navigated to a
named route.
final
- restorationScopeId → String?
-
The identifier to use for state restoration of this app.
final
-
routeInformationParser
→ RouteInformationParser<
Object> ? -
A delegate to parse the route information from the
routeInformationProvider into a generic data type to be processed by
the routerDelegate at a later stage.
final
- routeInformationProvider → RouteInformationProvider?
-
A object that provides route information through the
RouteInformationProvider.value and notifies its listener when its value
changes.
final
-
routerConfig
→ RouterConfig<
Object> ? -
An object to configure the underlying Router.
final
-
routerDelegate
→ RouterDelegate<
Object> ? -
A delegate that configures a widget, typically a Navigator, with
parsed result from the routeInformationParser.
final
-
routes
→ Map<
String, WidgetBuilder> ? -
The application's top-level routing table.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
-
shortcuts
→ Map<
ShortcutActivator, Intent> ? -
The default map of keyboard shortcuts to intents for the application.
final
- showPerformanceOverlay → bool
-
Turns on a performance overlay.
final
- showSemanticsDebugger → bool
-
Turns on an overlay that shows the accessibility information
reported by the framework.
final
-
supportedLocales
→ Iterable<
Locale> -
The list of locales that this app has been localized for.
final
- textStyle → TextStyle?
-
The default text style for Text in the application.
final
- title → String
-
A one-line description used by the device to identify the app for the user.
final
- useInheritedMediaQuery → bool
-
If true, an inherited MediaQuery will be used. If one is not available,
or this is false, one will be built from the window.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< WidgetsApp> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.protected">@protectedinherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
nonVirtual">@nonVirtualinherited
Static Properties
- debugAllowBannerOverride ↔ bool
-
If false, prevents the debug banner from being visible.
read / write
- debugShowWidgetInspectorOverride ↔ bool
-
If true, forces the widget inspector to be visible.
read / write
-
defaultActions
↔ Map<
Type, Action< Intent> > -
The default value of WidgetsApp.actions.
read / write
-
defaultShortcuts
→ Map<
ShortcutActivator, Intent> -
Generates the default shortcut key bindings based on the
defaultTargetPlatform.
read-only
- showPerformanceOverlayOverride ↔ bool
-
If true, forces the performance overlay to be visible in all instances.
read / write