pub struct NavigationDrawer {Show 13 fields
pub key: Option<KeyRef>,
pub background_color: Option<Color>,
pub shadow_color: Option<Color>,
pub surface_tint_color: Option<Color>,
pub elevation: Option<f64>,
pub indicator_color: Option<Color>,
pub indicator_shape: Option<ShapeBorderRef>,
pub children: Vec<WidgetRef>,
pub header: Option<WidgetRef>,
pub footer: Option<WidgetRef>,
pub selected_index: Option<i32>,
pub on_destination_selected: Option<ValueChanged<i32>>,
pub tile_padding: EdgeInsetsGeometry,
}Expand description
Material Design Navigation Drawer component.
On top of Drawers, Navigation drawers offer a persistent and convenient way to switch
between primary destinations in an app.
The style for the icons and text are not affected by parent
DefaultTextStyles or IconThemes but rather controlled by parameters or
the NavigationDrawerThemeData.
The children are a list of widgets to be displayed in the drawer.
These can be a mixture of any widgets, but there is special handling for
NavigationDrawerDestinations. They are treated as a group and when one is selected,
the on_destination_selected is called with the index
into the group that corresponds to the selected destination.
See also:
Scaffold::drawer, where one specifies aDrawerso that it can be shown.Scaffold::of, to obtain the currentScaffoldState, which manages the display and animation of the drawer.ScaffoldState::open_drawer, which displays itsDrawer, if any.- https://material.io/design/components/navigation-drawer.html
Fields§
§key: Option<KeyRef>§background_color: Option<Color>The background color of the Material that holds the NavigationDrawer’s
contents.
If this is null, then NavigationDrawerThemeData::background_color is used.
If that is also null, then it falls back to ColorScheme::surface_container_low.
shadow_color: Option<Color>The color used for the drop shadow to indicate elevation.
If null, NavigationDrawerThemeData::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 surface tint of the Material that holds the NavigationDrawer’s
contents.
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 this is null, then NavigationDrawerThemeData::surface_tint_color is used.
If that is also null, the default value is Colors::TRANSPARENT.
elevation: Option<f64>The elevation of the NavigationDrawer itself.
If null, NavigationDrawerThemeData::elevation is used. If that
is also null, it will be 1.0.
indicator_color: Option<Color>The color of the indicator_shape when this destination is
selected.
If this is null, NavigationDrawerThemeData::indicator_color is used.
If that is also null, defaults to ColorScheme::secondary_container.
indicator_shape: Option<ShapeBorderRef>The shape of the selected indicator.
If this is null, NavigationDrawerThemeData::indicator_shape is used.
If that is also null, defaults to StadiumBorder.
children: Vec<WidgetRef>Defines the appearance of the items within the navigation drawer.
The list contains NavigationDrawerDestination widgets and/or customized
widgets like headlines and dividers.
header: Option<WidgetRef>A widget to display at the top of the layout.
Typically used for titles, navigation bars, or other header content.
A widget to display at the bottom of the layout.
Typically used for actions, navigation controls, or other footer content.
selected_index: Option<i32>The index into destinations for the current selected
NavigationDrawerDestination or null if no destination is selected.
A valid selected_index satisfies
0 <= selected_index < number of
NavigationDrawerDestination. For an invalid
selected_index like -1, all destinations will appear
unselected.
on_destination_selected: Option<ValueChanged<i32>>Called when one of the NavigationDrawerDestination children is selected.
This callback usually updates the int passed to
selected_index.
Upon updating selected_index, the NavigationDrawer will be
rebuilt.
tile_padding: EdgeInsetsGeometryDefines the padding for NavigationDrawerDestination widgets (Drawer items).
Defaults to EdgeInsets.symmetric(horizontal: 12.0).
Implementations§
Sourcepub fn new(children: impl IntoIterator<Item = WidgetRef>) -> NavigationDrawer
pub fn new(children: impl IntoIterator<Item = WidgetRef>) -> NavigationDrawer
Creates a Material Design Navigation Drawer component.
Sourcepub fn key(self, key: KeyRef) -> NavigationDrawer
pub fn key(self, key: KeyRef) -> NavigationDrawer
Dart NavigationDrawer(key:).
Sourcepub fn header<K>(self, header: impl IntoWidget<K>) -> NavigationDrawer
pub fn header<K>(self, header: impl IntoWidget<K>) -> NavigationDrawer
Dart NavigationDrawer(header:).
Dart NavigationDrawer(footer:).
Sourcepub fn background_color(self, background_color: Color) -> NavigationDrawer
pub fn background_color(self, background_color: Color) -> NavigationDrawer
Dart NavigationDrawer(backgroundColor:).
Sourcepub fn shadow_color(self, shadow_color: Color) -> NavigationDrawer
pub fn shadow_color(self, shadow_color: Color) -> NavigationDrawer
Dart NavigationDrawer(shadowColor:).
Sourcepub fn surface_tint_color(self, surface_tint_color: Color) -> NavigationDrawer
pub fn surface_tint_color(self, surface_tint_color: Color) -> NavigationDrawer
Dart NavigationDrawer(surfaceTintColor:).
Sourcepub fn elevation(self, elevation: f64) -> NavigationDrawer
pub fn elevation(self, elevation: f64) -> NavigationDrawer
Dart NavigationDrawer(elevation:).
Sourcepub fn indicator_color(self, indicator_color: Color) -> NavigationDrawer
pub fn indicator_color(self, indicator_color: Color) -> NavigationDrawer
Dart NavigationDrawer(indicatorColor:).
Sourcepub fn indicator_shape(
self,
indicator_shape: impl Into<ShapeBorderRef>,
) -> NavigationDrawer
pub fn indicator_shape( self, indicator_shape: impl Into<ShapeBorderRef>, ) -> NavigationDrawer
Dart NavigationDrawer(indicatorShape:).
Sourcepub fn on_destination_selected(
self,
on_destination_selected: ValueChanged<i32>,
) -> NavigationDrawer
pub fn on_destination_selected( self, on_destination_selected: ValueChanged<i32>, ) -> NavigationDrawer
Dart NavigationDrawer(onDestinationSelected:).
Sourcepub fn selected_index(self, selected_index: Option<i32>) -> NavigationDrawer
pub fn selected_index(self, selected_index: Option<i32>) -> NavigationDrawer
Dart NavigationDrawer(selectedIndex:); None selects no destination.
Sourcepub fn tile_padding(
self,
tile_padding: impl Into<EdgeInsetsGeometry>,
) -> NavigationDrawer
pub fn tile_padding( self, tile_padding: impl Into<EdgeInsetsGeometry>, ) -> NavigationDrawer
Dart NavigationDrawer(tilePadding:).
Trait Implementations§
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 debug_check_constructor(&self)
fn debug_check_constructor(&self)
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.