NavRail class

A navigation rail widget that provides navigation buttons and actions.

NavRail is the core component used by NavPages to display navigation buttons. It supports both horizontal and vertical layouts, expandable states, and mobile-responsive behavior with overflow handling.

Example:

NavRail(
  direction: NavRailDirection.vertical,
  buttons: [
    NavRailButton(label: 'Home', icon: Icons.home),
    NavRailButton(label: 'Settings', icon: Icons.settings),
  ],
  expandable: true,
)
Inheritance

Constructors

Creates a NavRail widget.
const

Properties

actions List<NrButtonWidget>
The actions to display in the navigation rail.
final
backgroundColor Color?
The background color of the navigation rail.
final
buttons List<NrButtonWidget>
The buttons to display in the navigation rail.
final
direction NavRailDirection
The direction in which the navigation rail is laid out.
final
expandable bool
Whether the navigation rail can be expanded/collapsed.
final
expandableButtonHeight double
The height of the expandable button.
final
expanded bool
The initial expanded state of the navigation rail.
final
foregroundColor Color?
The foreground color for text and icons.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
labelPosition NavRailButtonLabelPosition?
The position of labels relative to icons in buttons.
final
leading Widget?
The leading widget for the navigation rail.
final
leadingOnTop bool
Whether the leading widget is on the top is true.
final
maxHeight double
The maximum height of the navigation rail.
final
maxWidth double
The maximum width of the navigation rail.
final
minHeight double
The minimum height of the navigation rail.
final
minWidth double
The minimum width of the navigation rail.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedActionIndex int
The index of the currently selected action button.
final
selectedBackgroundColor Color?
The background color for selected buttons.
final
selectedButtonIndex int
The index of the currently selected button.
final
selectedColor Color?
The color to use for selected buttons.
final
selectedSecondaryActionIndex int
The index of the currently selected secondary action button.
final
showActionSelectedIndex bool
Whether to show the selected action index.
final
showSecondaryActionSelectedIndex bool
Whether to show the selected secondary action index.
final
smallLeading Widget?
The small leading widget for the navigation rail.
final
unselectedBackgroundColor Color?
The background color for unselected buttons.
final
unselectedColor Color?
The color to use for unselected buttons.
final
verticleScrolling bool
Whether the navigation rail can be scrolled vertically.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<NavRail>
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, int wrapWidth = 65}) 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