CupertinoTabScaffold class

Implements a tabbed iOS application's root layout and behavior structure.

The scaffold lays out the tab bar at the bottom and the content between or behind the tab bar.

A tabBar and a tabBuilder are required. The CupertinoTabScaffold will automatically listen to the provided CupertinoTabBar's tap callbacks to change the active tab.

A controller can be used to provide an initially selected tab index and manage subsequent tab changes. If a controller is not specified, the scaffold will create its own CupertinoTabController and manage it internally. Otherwise it's up to the owner of controller to call dispose on it after finish using it.

Tabs' contents are built with the provided tabBuilder at the active tab index. The tabBuilder must be able to build the same number of pages as there are tabBar items. Inactive tabs will be moved Offstage and their animations disabled.

Adding/removing tabs, or changing the order of tabs is supported but not recommended. Doing so is against the iOS human interface guidelines, and CupertinoTabScaffold may lose some tabs' state in the process.

Use CupertinoTabView as the root widget of each tab to support tabs with parallel navigation state and history. Since each CupertinoTabView contains a Navigator, rebuilding the CupertinoTabView with a different WidgetBuilder instance in CupertinoTabView.builder will not recreate the CupertinoTabView's navigation stack or update its UI. To update the contents of the CupertinoTabView after it's built, trigger a rebuild (via State.setState, for instance) from its descendant rather than from its ancestor.

A sample code implementing a typical iOS information architecture with tabs.
link

To create a local project with this code sample, run:
flutter create --sample=cupertino.CupertinoTabScaffold.1 mysample

To push a route above all tabs instead of inside the currently selected one (such as when showing a dialog on top of this scaffold), use Navigator.of(rootNavigator: true) from inside the BuildContext of a CupertinoTabView.

See also:

Inheritance

Constructors

CupertinoTabScaffold({Key? key, required CupertinoTabBar tabBar, required IndexedWidgetBuilder tabBuilder, CupertinoTabController? controller, Color? backgroundColor, bool resizeToAvoidBottomInset = true, String? restorationId})
Creates a layout for applications with a tab bar at the bottom.

Properties

backgroundColor Color?
The color of the widget that underlies the entire scaffold.
final
controller CupertinoTabController?
Controls the currently selected tab index of the tabBar, as well as the active tab index of the tabBuilder. Providing a different controller will also update the scaffold's current active index to the new controller's index value.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
resizeToAvoidBottomInset bool
Whether the body should size itself to avoid the window's bottom inset.
final
restorationId String?
Restoration ID to save and restore the state of the CupertinoTabScaffold.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tabBar CupertinoTabBar
The tabBar is a CupertinoTabBar drawn at the bottom of the screen that lets the user switch between different tabs in the main content area when present.
final
tabBuilder IndexedWidgetBuilder
An IndexedWidgetBuilder that's called when tabs become active.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CupertinoTabScaffold>
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.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent 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.
inherited