pub struct NavigationBar {Show 17 fields
pub key: Option<KeyRef>,
pub animation_duration: Option<Duration>,
pub selected_index: usize,
pub destinations: Vec<WidgetRef>,
pub on_destination_selected: Option<ValueChanged<usize>>,
pub background_color: Option<Color>,
pub elevation: Option<f64>,
pub shadow_color: Option<Color>,
pub surface_tint_color: Option<Color>,
pub indicator_color: Option<Color>,
pub indicator_shape: Option<ShapeBorderRef>,
pub height: Option<f64>,
pub label_behavior: Option<NavigationDestinationLabelBehavior>,
pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub label_text_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>,
pub label_padding: Option<EdgeInsetsGeometry>,
pub maintain_bottom_view_padding: bool,
}Expand description
Material 3 Navigation Bar component.
Learn more about NavigationBar on the Flutter YouTube channel.
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::visual_density.
The MediaQueryData::text_scaler 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).
See also:
Fields§
§key: Option<KeyRef>§animation_duration: Option<Duration>Determines the transition time for each destination as it goes between selected and unselected.
selected_index: usizeDetermines which one of the destinations is currently selected.
When this is updated, the destination (from destinations) at
selected_index goes from unselected to selected.
destinations: Vec<WidgetRef>The list of destinations (usually NavigationDestinations) in this
NavigationBar.
When selected_index is updated, the destination from this
list at selected_index will animate from 0 (unselected) to
1.0 (selected). When the animation is increasing or completed, the destination is
considered selected, when the animation is decreasing or dismissed, the destination
is considered unselected.
on_destination_selected: Option<ValueChanged<usize>>Called when one of the destinations is selected.
This callback usually updates the int passed to selected_index.
Upon updating selected_index, the NavigationBar will be
rebuilt.
background_color: Option<Color>The color of the NavigationBar itself.
If null, NavigationBarThemeData::background_color is used. If that
is also null, then if ThemeData::use_material3 is true, the value is
ColorScheme::surface_container. If that is false, the default blends
ColorScheme::surface and ColorScheme::on_surface using an ElevationOverlay.
elevation: Option<f64>The elevation of the NavigationBar itself.
If null, NavigationBarThemeData::elevation is used. If that
is also null, then if ThemeData::use_material3 is true then it will
be 3.0 otherwise 0.0.
shadow_color: Option<Color>The color used for the drop shadow to indicate elevation.
If null, NavigationBarThemeData::shadow_color is used. If that
is also null, the default value is Colors::TRANSPARENT which
indicates that no drop shadow will be displayed.
See Material::shadow_color for more details on drop shadows.
surface_tint_color: Option<Color>The color used as an overlay on background_color to
indicate elevation.
This is not recommended for use. Material 3 spec
introduced a set of tone-based surfaces and surface containers in its ColorScheme,
which provide more flexibility. The intention is to eventually remove surface tint color from
the framework.
If null, NavigationBarThemeData::surface_tint_color is used. If that
is also null, the default value is Colors::TRANSPARENT.
See Material::surface_tint_color for more details on how this
overlay is applied.
indicator_color: Option<Color>The color of the indicator_shape when this destination is
selected.
If null, NavigationBarThemeData::indicator_color is used. If that
is also null and ThemeData::use_material3 is true, ColorScheme::secondary_container
is used. Otherwise, ColorScheme::secondary with an opacity of 0.24 is used.
indicator_shape: Option<ShapeBorderRef>The shape of the selected indicator.
If null, NavigationBarThemeData::indicator_shape is used. If that
is also null and ThemeData::use_material3 is true, StadiumBorder is used.
Otherwise, RoundedRectangleBorder with a circular border radius of 16 is used.
height: Option<f64>The height of the NavigationBar itself.
If this is used in Scaffold::bottom_navigation_bar and the scaffold is
full-screen, the safe area padding is also added to the height
automatically.
The height does not adjust with ThemeData::visual_density or
MediaQueryData::text_scaler as this component loses usability at
larger and smaller sizes due to the truncating of labels or smaller tap
targets.
If null, NavigationBarThemeData::height is used. If that
is also null, the default is 80.
label_behavior: Option<NavigationDestinationLabelBehavior>Defines how the destinations’ labels will be laid out and when
they’ll be displayed.
Can be used to show all labels, show only the selected label, or hide all labels.
If null, NavigationBarThemeData::label_behavior is used. If that
is also null, the default is
NavigationDestinationLabelBehavior::AlwaysShow.
overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>The highlight color that’s typically used to indicate that
the NavigationDestination is focused, hovered, or pressed.
label_text_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>The text style of the label.
If null, NavigationBarThemeData::label_text_style is used. If that
is also null, the default text style is TextTheme::label_medium with
ColorScheme::on_surface when the destination is selected, and
ColorScheme::on_surface_variant when the destination is unselected, and
ColorScheme::on_surface_variant with an opacity of 0.38 when the
destination is disabled.
If ThemeData::use_material3 is false, then the default text style is
TextTheme::label_small with ColorScheme::on_surface.
label_padding: Option<EdgeInsetsGeometry>The padding around the NavigationDestination::label widget.
When label_padding is null,
NavigationBarThemeData::label_padding is used. If that is also null, the default
padding is 4 pixels on the top.
maintain_bottom_view_padding: boolSpecifies whether the underlying SafeArea should maintain the bottom
MediaQueryData::view_padding instead of the bottom MediaQueryData::padding.
When true, this will prevent the NavigationBar from shifting when opening a
software keyboard due to the change in the padding value, especially when the
app uses SystemUiMode::EdgeToEdge, which renders the system bars over the
application instead of outside it.
Defaults to false.
See also:
SafeArea::maintain_bottom_view_padding, which specifies whether theSafeAreashould maintain the bottomMediaQueryData::view_padding.SystemUiMode::EdgeToEdge, which sets a fullscreen display with status and navigation elements rendered over the application.
Implementations§
Sourcepub fn new(destinations: impl IntoIterator<Item = WidgetRef>) -> NavigationBar
pub fn new(destinations: impl IntoIterator<Item = WidgetRef>) -> NavigationBar
Creates a Material 3 Navigation Bar component.
The value of destinations must be a list of two or more
NavigationDestination values.
Sourcepub fn key(self, key: KeyRef) -> NavigationBar
pub fn key(self, key: KeyRef) -> NavigationBar
Dart NavigationBar(key:).
Sourcepub fn animation_duration(self, animation_duration: Duration) -> NavigationBar
pub fn animation_duration(self, animation_duration: Duration) -> NavigationBar
Dart NavigationBar(animationDuration:).
Sourcepub fn selected_index(self, selected_index: usize) -> NavigationBar
pub fn selected_index(self, selected_index: usize) -> NavigationBar
Dart NavigationBar(selectedIndex:).
Sourcepub fn on_destination_selected(
self,
on_destination_selected: impl Fn(&mut App, usize) + 'static,
) -> NavigationBar
pub fn on_destination_selected( self, on_destination_selected: impl Fn(&mut App, usize) + 'static, ) -> NavigationBar
Dart NavigationBar(onDestinationSelected:).
Sourcepub fn background_color(self, background_color: Color) -> NavigationBar
pub fn background_color(self, background_color: Color) -> NavigationBar
Dart NavigationBar(backgroundColor:).
Sourcepub fn elevation(self, elevation: f64) -> NavigationBar
pub fn elevation(self, elevation: f64) -> NavigationBar
Dart NavigationBar(elevation:).
Sourcepub fn shadow_color(self, shadow_color: Color) -> NavigationBar
pub fn shadow_color(self, shadow_color: Color) -> NavigationBar
Dart NavigationBar(shadowColor:).
Sourcepub fn surface_tint_color(self, surface_tint_color: Color) -> NavigationBar
pub fn surface_tint_color(self, surface_tint_color: Color) -> NavigationBar
Dart NavigationBar(surfaceTintColor:).
Sourcepub fn indicator_color(self, indicator_color: Color) -> NavigationBar
pub fn indicator_color(self, indicator_color: Color) -> NavigationBar
Dart NavigationBar(indicatorColor:).
Sourcepub fn indicator_shape(
self,
indicator_shape: impl Into<ShapeBorderRef>,
) -> NavigationBar
pub fn indicator_shape( self, indicator_shape: impl Into<ShapeBorderRef>, ) -> NavigationBar
Dart NavigationBar(indicatorShape:).
Sourcepub fn height(self, height: f64) -> NavigationBar
pub fn height(self, height: f64) -> NavigationBar
Dart NavigationBar(height:).
Sourcepub fn label_behavior(
self,
label_behavior: NavigationDestinationLabelBehavior,
) -> NavigationBar
pub fn label_behavior( self, label_behavior: NavigationDestinationLabelBehavior, ) -> NavigationBar
Dart NavigationBar(labelBehavior:).
Sourcepub fn overlay_color(
self,
overlay_color: WidgetStatePropertyRef<Option<Color>>,
) -> NavigationBar
pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> NavigationBar
Dart NavigationBar(overlayColor:).
Sourcepub fn label_text_style(
self,
label_text_style: WidgetStatePropertyRef<Option<TextStyle>>,
) -> NavigationBar
pub fn label_text_style( self, label_text_style: WidgetStatePropertyRef<Option<TextStyle>>, ) -> NavigationBar
Dart NavigationBar(labelTextStyle:).
Sourcepub fn label_padding(
self,
label_padding: impl Into<EdgeInsetsGeometry>,
) -> NavigationBar
pub fn label_padding( self, label_padding: impl Into<EdgeInsetsGeometry>, ) -> NavigationBar
Dart NavigationBar(labelPadding:).
Sourcepub fn maintain_bottom_view_padding(
self,
maintain_bottom_view_padding: bool,
) -> NavigationBar
pub fn maintain_bottom_view_padding( self, maintain_bottom_view_padding: bool, ) -> NavigationBar
Dart NavigationBar(maintainBottomViewPadding:).
Trait Implementations§
Source§fn debug_check_constructor(&self)
fn debug_check_constructor(&self)
Source§fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
this is PreferredSizeWidget: a widget that implements PreferredSizeWidget
answers with itself, which is what a parent asking an erased child for its preferred
size reads.Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.