NavigationBar class Null safety

Material 3 Navigation Bar component.

Navigation bars offer a persistent and convenient way to switch between primary destinations in an app.

This widget does not adjust its size with the ThemeData.visualDensity.

The MediaQueryData.textScaleFactor does not adjust the size of this widget but rather the size of the Tooltips displayed on long presses of the destinations.

The style for the icons and text are not affected by parent DefaultTextStyles or IconThemes but rather controlled by parameters or the NavigationBarThemeData.

This widget holds a collection of destinations (usually NavigationDestinations).

This example shows a NavigationBar as it is used within a Scaffold widget. The NavigationBar has three NavigationDestination widgets and the selectedIndex is set to index 0. The onDestinationSelected callback changes the selected item's index and displays a corresponding widget in the body of the Scaffold.
To create a local project with this code sample, run:
flutter create --sample=material.NavigationBar.1 mysample

See also:

Inheritance

Constructors

Creates a Material 3 Navigation Bar component. [...]
const

Properties

animationDuration Duration?
Determines the transition time for each destination as it goes between selected and unselected.
final
backgroundColor Color?
The color of the NavigationBar itself. [...]
final
destinations List<Widget>
The list of destinations (usually NavigationDestinations) in this NavigationBar. [...]
final
elevation double?
The elevation of the NavigationBar itself. [...]
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
height double?
The height of the NavigationBar itself. [...]
final
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
labelBehavior NavigationDestinationLabelBehavior?
Defines how the destinations' labels will be laid out and when they'll be displayed. [...]
final
onDestinationSelected ValueChanged<int>?
Called when one of the destinations is selected. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
selectedIndex int
Determines which one of the destinations is currently selected. [...]
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
inherited
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. [...]
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, inherited