CupertinoNavigationBar class

An iOS-styled navigation bar.

The navigation bar is a toolbar that minimally consists of a widget, normally a page title, in the middle of the toolbar.

It also supports a leading and trailing widget before and after the middle widget while keeping the middle widget centered.

The leading widget will automatically be a back chevron icon button (or a close button in case of a fullscreen dialog) to pop the current route if none is provided and automaticallyImplyLeading is true (true by default).

The middle widget will automatically be a title text from the current CupertinoPageRoute if none is provided and automaticallyImplyMiddle is true (true by default).

It should be placed at top of the screen and automatically accounts for the OS's status bar.

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 transitionBetweenRoutes is true, this navigation bar will transition on top of the routes instead of inside them if the route being transitioned to also has a CupertinoNavigationBar or a CupertinoSliverNavigationBar with transitionBetweenRoutes set to true. If transitionBetweenRoutes is true, none of the Widget parameters can contain a key in its subtree since that widget will exist in multiple places in the tree simultaneously.

By default, only one CupertinoNavigationBar or CupertinoSliverNavigationBar should be present in each PageRoute to support the default transitions. Use transitionBetweenRoutes or heroTag to customize the transition behavior for multiple navigation bars per route.

When used in a CupertinoPageScaffold, CupertinoPageScaffold.navigationBar 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 CupertinoNavigationBar placed in a CupertinoPageScaffold. Since backgroundColor's opacity is not 1.0, there is a blur effect and content slides underneath.

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

See also:

Implemented types


CupertinoNavigationBar({Key? key, Widget? leading, bool automaticallyImplyLeading = true, bool automaticallyImplyMiddle = true, String? previousPageTitle, Widget? middle, Widget? trailing, Border? border = _kDefaultNavBarBorder, Color? backgroundColor, Brightness? brightness, EdgeInsetsDirectional? padding, bool transitionBetweenRoutes = true, Object heroTag = _defaultHeroTag})
Creates a navigation bar in the iOS style.


automaticallyImplyLeading bool
Controls whether we should try to imply the leading widget if null.
automaticallyImplyMiddle bool
Controls whether we should try to imply the middle widget if null.
backgroundColor Color?
The background color of the navigation 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 navigation bar. By default renders a single pixel bottom border side.
brightness Brightness?
The brightness of the specified backgroundColor.
hashCode int
The hash code for this object.
no setterinherited
heroTag Object
Tag for the navigation bar's Hero widget if transitionBetweenRoutes is true.
key Key?
Controls how one widget replaces another widget in the tree.
leading Widget?
Widget to place at the start of the navigation bar. Normally a back button for a normal page or a cancel button for full page dialogs.
middle Widget?
Widget to place in the middle of the navigation bar. Normally a title or a segmented control.
padding EdgeInsetsDirectional?
Padding for the contents of the navigation bar.
preferredSize Size
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
previousPageTitle String?
Manually specify the previous route's title when automatically implying the leading back button.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
trailing Widget?
Widget to place at the end of the navigation bar. Normally additional actions taken on the page such as a search or edit function.
transitionBetweenRoutes bool
Whether to transition between navigation bars.


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() State<CupertinoNavigationBar>
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.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
shouldFullyObstruct(BuildContext context) bool
True if the navigation bar's background color has no transparency.
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.