CupertinoTabBar class

An iOS-styled bottom navigation tab bar.

Displays multiple tabs using BottomNavigationBarItem with one tab being active, the first tab by default.

This StatelessWidget doesn't store the active tab itself. You must listen to the onTap callbacks and call setState with a new currentIndex for the new selection to reflect. This can also be done automatically by wrapping this with a CupertinoTabScaffold.

Tab changes typically trigger a switch between Navigators, each with its own navigation stack, per standard iOS design. This can be done by using CupertinoTabViews inside each tab builder in CupertinoTabScaffold.

If the given backgroundColor's opacity is not 1.0 (which is the case by default), it will produce a blurring effect to the content behind it.

When used as CupertinoTabScaffold.tabBar, by default CupertinoTabBar disables text scaling to match the native iOS behavior. To override this behavior, wrap each of the navigationBar's components inside a MediaQuery with the desired TextScaler.

This example shows a CupertinoTabBar placed in a CupertinoTabScaffold.

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

See also:

Implemented types


CupertinoTabBar({Key? key, required List<BottomNavigationBarItem> items, ValueChanged<int>? onTap, int currentIndex = 0, Color? backgroundColor, Color? activeColor, Color inactiveColor = _kDefaultTabBarInactiveColor, double iconSize = 30.0, double height = _kTabBarHeight, Border? border = const Border(top: BorderSide(color: _kDefaultTabBarBorderColor, width: 0.0))})
Creates a tab bar in the iOS style.


activeColor Color?
The foreground color of the icon and title for the BottomNavigationBarItem of the selected tab.
backgroundColor Color?
The background color of the tab bar. If it contains transparency, the tab bar will automatically produce a blurring effect to the content behind it.
border Border?
The border of the CupertinoTabBar.
currentIndex int
The index into items of the current active item.
hashCode int
The hash code for this object.
no setterinherited
height double
The height of the CupertinoTabBar.
iconSize double
The size of all of the BottomNavigationBarItem icons.
inactiveColor Color
The foreground color of the icon and title for the BottomNavigationBarItems in the unselected state.
items List<BottomNavigationBarItem>
The interactive items laid out within the bottom navigation bar.
key Key?
Controls how one widget replaces another widget in the tree.
onTap ValueChanged<int>?
The callback that is called when a item is tapped.
preferredSize Size
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
copyWith({Key? key, List<BottomNavigationBarItem>? items, Color? backgroundColor, Color? activeColor, Color? inactiveColor, double? iconSize, double? height, Border? border, int? currentIndex, ValueChanged<int>? onTap}) CupertinoTabBar
Create a clone of the current CupertinoTabBar but with provided parameters overridden.
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
opaque(BuildContext context) bool
Indicates whether the tab bar is fully opaque or can have contents behind it show through it.
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 =}) String
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.