NavigationRail constructor
- Key? key,
- Color? backgroundColor,
- bool extended = false,
- Widget? leading,
- Widget? trailing,
- required List<
NavigationRailDestination> destinations, - required int? selectedIndex,
- ValueChanged<
int> ? onDestinationSelected, - double? elevation,
- double? groupAlignment,
- NavigationRailLabelType? labelType,
- TextStyle? unselectedLabelTextStyle,
- TextStyle? selectedLabelTextStyle,
- IconThemeData? unselectedIconTheme,
- IconThemeData? selectedIconTheme,
- double? minWidth,
- double? minExtendedWidth,
- bool? useIndicator,
- Color? indicatorColor,
- ShapeBorder? indicatorShape,
Creates a Material Design navigation rail.
The value of destinations
must be a list of zero or more
NavigationRailDestination values.
If elevation
is specified, it must be non-negative.
If minWidth
is specified, it must be non-negative, and if
minExtendedWidth
is specified, it must be non-negative and greater than
minWidth
.
The extended
argument can only be set to true when the labelType
is
null or NavigationRailLabelType.none.
If backgroundColor
, elevation
, groupAlignment
, labelType
,
unselectedLabelTextStyle
, selectedLabelTextStyle
,
unselectedIconTheme
, or selectedIconTheme
are null, then their
NavigationRailThemeData values will be used. If the corresponding
NavigationRailThemeData property is null, then the navigation rail
defaults are used. See the individual properties for more information.
Typically used within a Row that defines the Scaffold.body property.
Implementation
const NavigationRail({
super.key,
this.backgroundColor,
this.extended = false,
this.leading,
this.trailing,
required this.destinations,
required this.selectedIndex,
this.onDestinationSelected,
this.elevation,
this.groupAlignment,
this.labelType,
this.unselectedLabelTextStyle,
this.selectedLabelTextStyle,
this.unselectedIconTheme,
this.selectedIconTheme,
this.minWidth,
this.minExtendedWidth,
this.useIndicator,
this.indicatorColor,
this.indicatorShape,
}) : assert(selectedIndex == null || (0 <= selectedIndex && selectedIndex < destinations.length)),
assert(elevation == null || elevation > 0),
assert(minWidth == null || minWidth > 0),
assert(minExtendedWidth == null || minExtendedWidth > 0),
assert((minWidth == null || minExtendedWidth == null) || minExtendedWidth >= minWidth),
assert(!extended || (labelType == null || labelType == NavigationRailLabelType.none));