NavigationRail constructor
const
NavigationRail({
- Key? key,
- Color? backgroundColor,
- NavigationRailAlignment alignment = NavigationRailAlignment.center,
- Axis direction = Axis.vertical,
- double? spacing,
- NavigationLabelType labelType = NavigationLabelType.selected,
- NavigationLabelPosition labelPosition = NavigationLabelPosition.bottom,
- NavigationLabelSize labelSize = NavigationLabelSize.small,
- EdgeInsetsGeometry? padding,
- BoxConstraints? constraints,
- int? index,
- ValueChanged<
int> ? onSelected, - double? surfaceOpacity,
- double? surfaceBlur,
- bool expanded = true,
- bool keepMainAxisSize = false,
- bool keepCrossAxisSize = false,
- required List<
NavigationBarItem> children,
Creates a NavigationRail with the specified configuration and items.
The children parameter is required and should contain NavigationBarItem
widgets that define the navigation destinations. Other parameters control
the rail's appearance, behavior, and layout characteristics.
Default values provide a sensible vertical rail configuration suitable for most sidebar navigation scenarios. Customization allows adaptation to specific layout requirements and design systems.
Parameters:
children(Listalignment(NavigationRailAlignment, default: center): Item alignment along main axisdirection(Axis, default: vertical): Layout orientation of the raillabelType(NavigationLabelType, default: selected): When to show labelslabelPosition(NavigationLabelPosition, default: bottom): Label positioningindex(int?, optional): Currently selected item indexonSelected(ValueChanged
Example:
NavigationRail(
alignment: NavigationRailAlignment.start,
labelType: NavigationLabelType.all,
index: currentIndex,
onSelected: (index) => _navigate(index),
children: navigationItems,
)
Implementation
const NavigationRail({
super.key,
this.backgroundColor,
this.alignment = NavigationRailAlignment.center,
this.direction = Axis.vertical,
this.spacing,
this.labelType = NavigationLabelType.selected,
this.labelPosition = NavigationLabelPosition.bottom,
this.labelSize = NavigationLabelSize.small,
this.padding,
this.constraints,
this.index,
this.onSelected,
this.surfaceOpacity,
this.surfaceBlur,
this.expanded = true,
this.keepMainAxisSize = false,
this.keepCrossAxisSize = false,
required this.children,
});