TabBar class Null safety

A material design widget that displays a horizontal row of tabs.

Typically created as the AppBar.bottom part of an AppBar and in conjunction with a TabBarView.

If a TabController is not provided, then a DefaultTabController ancestor must be provided instead. The tab controller's TabController.length must equal the length of the tabs list and the length of the TabBarView.children list.

Requires one of its ancestors to be a Material widget.

Uses values from TabBarTheme if it is set in the current context.

This sample shows the implementation of TabBar and TabBarView using a DefaultTabController. Each Tab corresponds to a child of the TabBarView in the order they are written.
To create a local project with this code sample, run:
flutter create --sample=material.TabBar.1 mysample

TabBar can also be implemented by using a TabController which provides more options to control the behavior of the TabBar and TabBarView. This can be used instead of a DefaultTabController, demonstrated below.
To create a local project with this code sample, run:
flutter create --sample=material.TabBar.2 mysample

See also:

  • TabBarView, which displays page views that correspond to each tab.
  • TabBar, which is used to display the Tab that corresponds to each page of the TabBarView.
Implemented types


TabBar({Key? key, required List<Widget> tabs, TabController? controller, bool isScrollable = false, EdgeInsetsGeometry? padding, Color? indicatorColor, bool automaticIndicatorColorAdjustment = true, double indicatorWeight = 2.0, EdgeInsetsGeometry indicatorPadding =, Decoration? indicator, TabBarIndicatorSize? indicatorSize, Color? labelColor, TextStyle? labelStyle, EdgeInsetsGeometry? labelPadding, Color? unselectedLabelColor, TextStyle? unselectedLabelStyle, DragStartBehavior dragStartBehavior = DragStartBehavior.start, MaterialStateProperty<Color?>? overlayColor, MouseCursor? mouseCursor, bool? enableFeedback, ValueChanged<int>? onTap, ScrollPhysics? physics})
Creates a material design tab bar. [...]


automaticIndicatorColorAdjustment bool
Whether this tab bar should automatically adjust the indicatorColor. [...]
controller TabController?
This widget's selection and animation state. [...]
dragStartBehavior DragStartBehavior
Determines the way that drag start behavior is handled. [...]
enableFeedback bool?
Whether detected gestures should provide acoustic and/or haptic feedback. [...]
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
indicator Decoration?
Defines the appearance of the selected tab indicator. [...]
indicatorColor Color?
The color of the line that appears below the selected tab. [...]
indicatorPadding EdgeInsetsGeometry
Padding for indicator. This property will now no longer be ignored even if indicator is declared or provided by TabBarTheme [...]
indicatorSize TabBarIndicatorSize?
Defines how the selected tab indicator's size is computed. [...]
indicatorWeight double
The thickness of the line that appears below the selected tab. [...]
isScrollable bool
Whether this tab bar can be scrolled horizontally. [...]
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
labelColor Color?
The color of selected tab labels. [...]
labelPadding EdgeInsetsGeometry?
The padding added to each of the tab labels. [...]
labelStyle TextStyle?
The text style of the selected tab labels. [...]
mouseCursor MouseCursor?
The cursor for a mouse pointer when it enters or is hovering over the individual tab widgets. [...]
onTap ValueChanged<int>?
An optional callback that's called when the TabBar is tapped. [...]
overlayColor MaterialStateProperty<Color?>?
Defines the ink response focus, hover, and splash colors. [...]
padding EdgeInsetsGeometry?
The amount of space by which to inset the tab bar. [...]
physics ScrollPhysics?
How the TabBar's scroll view should respond to user input. [...]
preferredSize Size
A size whose height depends on if the tabs have both icons and text. [...]
read-only, override
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
tabHasTextAndIcon bool
Returns whether the TabBar contains a tab with both text and icon. [...]
tabs List<Widget>
Typically a list of two or more Tab widgets. [...]
unselectedLabelColor Color?
The color of unselected tab labels. [...]
unselectedLabelStyle TextStyle?
The text style of the unselected tab labels. [...]


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
createState() State<TabBar>
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 =}) 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. [...]
@nonVirtual, inherited