Skip to main content

BottomNavigationBarItem

Struct BottomNavigationBarItem 

Source
pub struct BottomNavigationBarItem {
    pub key: Option<KeyRef>,
    pub icon: WidgetRef,
    pub active_icon: WidgetRef,
    pub label: Option<String>,
    pub background_color: Option<AnyColor>,
    pub tooltip: Option<String>,
    pub semantics_label: Option<String>,
}
Expand description

An interactive button within either material’s BottomNavigationBar or the iOS themed CupertinoTabBar with an icon and title.

This class is rarely used in isolation. It is typically embedded in one of the bottom navigation widgets above.

See also:

Fields§

§key: Option<KeyRef>

A key to be passed through to the resultant widget.

This allows the identification of different BottomNavigationBarItems through their keys.

When changing the number of bar items in response to a bar item being tapped, giving each item a key will allow the inkwell / splash animation to be correctly positioned.

§icon: WidgetRef

The icon of the item.

Typically the icon is an Icon or an ImageIcon widget. If another type of widget is provided then it should configure itself to match the current IconTheme size and color.

If active_icon is provided, this will only be displayed when the item is not selected.

To make the bottom navigation bar more accessible, consider choosing an icon with a stroked and filled version, such as Icons.cloud and Icons.cloud_queue. icon should be set to the stroked version and active_icon to the filled version.

If a particular icon doesn’t have a stroked or filled version, then don’t pair unrelated icons. Instead, make sure to use a BottomNavigationBarType.shifting.

§active_icon: WidgetRef

An alternative icon displayed when this bottom navigation item is selected.

If this icon is not provided, the bottom navigation bar will display icon in either state.

§label: Option<String>

The text label for this BottomNavigationBarItem.

This will be used to create a Text widget to put in the bottom navigation bar.

§background_color: Option<AnyColor>

The color of the background radial animation for material BottomNavigationBar.

If the navigation bar’s type is BottomNavigationBarType.shifting, then the entire bar is flooded with the background_color when this item is tapped. This will override BottomNavigationBar.backgroundColor.

Not used for CupertinoTabBar. Control the invariant bar color directly via CupertinoTabBar.backgroundColor.

§tooltip: Option<String>

The text to display in the Tooltip for this BottomNavigationBarItem.

A Tooltip will only appear on this item if tooltip is set to a non-empty string.

Defaults to None, in which case the tooltip is not shown.

§semantics_label: Option<String>

The semantic label for this BottomNavigationBarItem.

This is used by accessibility tools to describe the item. When provided, it overrides the default label String when read by accessibility tools.

This is useful when the visual label does not fully describe the action or destination, or when you want to provide additional context for screen reader users.

If null, the default semantic description is used.

Implementations§

Source§

impl BottomNavigationBarItem

Source

pub fn new<K>(icon: impl IntoWidget<K>) -> BottomNavigationBarItem

Creates an item that is used with BottomNavigationBar.items; Dart’s optional named arguments are the setters.

The argument icon should not be None and the argument label should not be None when used in a Material Design’s BottomNavigationBar.

Source

pub fn key(self, key: KeyRef) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(key:).

Source

pub fn label(self, label: impl Into<String>) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(label:).

Source

pub fn active_icon<K>( self, active_icon: impl IntoWidget<K>, ) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(activeIcon:).

Source

pub fn background_color( self, background_color: impl Into<AnyColor>, ) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(backgroundColor:).

Source

pub fn tooltip(self, tooltip: impl Into<String>) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(tooltip:).

Source

pub fn semantics_label( self, semantics_label: impl Into<String>, ) -> BottomNavigationBarItem

Dart BottomNavigationBarItem(semanticsLabel:).

Trait Implementations§

Source§

impl Clone for BottomNavigationBarItem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BottomNavigationBarItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>