WidgetsApp class

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.

Find references to many of the widgets that WidgetsApp wraps in the "See also" section.

See also:



WidgetsApp({Key key, GlobalKey<NavigatorState> navigatorKey, RouteFactory onGenerateRoute, InitialRouteListFactory onGenerateInitialRoutes, RouteFactory onUnknownRoute, List<NavigatorObserver> navigatorObservers: const [], String initialRoute, PageRoute<T> pageRouteBuilder(RouteSettings settings, WidgetBuilder builder), Widget home, Map<String, WidgetBuilder> routes: const {}, 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('en', 'US')], bool showPerformanceOverlay: false, bool checkerboardRasterCacheImages: false, bool checkerboardOffscreenLayers: false, bool showSemanticsDebugger: false, bool debugShowWidgetInspector: false, bool debugShowCheckedModeBanner: true, InspectorSelectButtonBuilder inspectorSelectButtonBuilder, Map<LogicalKeySet, Intent> shortcuts, Map<Type, Action<Intent>> actions})
Creates a widget that wraps a number of widgets that are commonly required for an application. [...]


actions Map<Type, Action<Intent>>
The default map of intent keys to actions for the application. [...]
builder TransitionBuilder
A builder for inserting widgets above the Navigator but below the other widgets created by the WidgetsApp widget, or for replacing the Navigator entirely. [...]
checkerboardOffscreenLayers bool
Checkerboards layers rendered to offscreen bitmaps. [...]
checkerboardRasterCacheImages bool
Checkerboards raster cache images. [...]
color Color
The primary color to use for the application in the operating system interface. [...]
debugShowCheckedModeBanner bool
Turns on a little "DEBUG" banner in checked mode to indicate that the app is in checked mode. This is on by default (in checked mode), to turn it off, set the constructor argument to false. In release mode this has no effect. [...]
debugShowWidgetInspector bool
Turns on an overlay that enables inspecting the widget tree. [...]
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
home Widget
The widget for the default route of the app (Navigator.defaultRouteName, which is /). [...]
initialRoute String
The name of the first route to show, if a Navigator is built. [...]
inspectorSelectButtonBuilder InspectorSelectButtonBuilder
Builds the widget the WidgetInspector uses to switch between view and inspect modes. [...]
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
locale Locale
The initial locale for this app's Localizations widget is based on this value. [...]
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. [...]
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. [...]
localizationsDelegates Iterable<LocalizationsDelegate>
The delegates for this app's Localizations widget. [...]
A key to use when building the Navigator. [...]
The list of observers for the Navigator created for this app. [...]
onGenerateInitialRoutes InitialRouteListFactory
The routes generator callback used for generating initial routes if initialRoute is provided. [...]
onGenerateRoute RouteFactory
The route generator callback used when the app is navigated to a named route. [...]
onGenerateTitle GenerateAppTitle
If non-null this callback function is called to produce the app's title string, otherwise title is used. [...]
onUnknownRoute RouteFactory
Called when onGenerateRoute fails to generate a route, except for the initialRoute. [...]
pageRouteBuilder PageRoute<T> Function<T>(RouteSettings settings, WidgetBuilder builder)
The PageRoute generator callback used when the app is navigated to a named route. [...]
routes Map<String, WidgetBuilder>
The application's top-level routing table. [...]
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shortcuts Map<LogicalKeySet, Intent>
The default map of keyboard shortcuts to intents for the application. [...]
showPerformanceOverlay bool
Turns on a performance overlay. [...]
showSemanticsDebugger bool
Turns on an overlay that shows the accessibility information reported by the framework.
supportedLocales Iterable<Locale>
The list of locales that this app has been localized for. [...]
textStyle TextStyle
The default text style for Text in the application.
title String
A one-line description used by the device to identify the app for the user. [...]


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
createState() → _WidgetsAppState
Creates the mutable state for this widget at a given location in the tree. [...]
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel: DiagnosticLevel.info}) String
Returns a string representation of this object.
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited

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<LogicalKeySet, Intent>
Generates the default shortcut key bindings based on the defaultTargetPlatform. [...]
showPerformanceOverlayOverride bool
If true, forces the performance overlay to be visible in all instances. [...]
read / write