pub struct Drawer {
pub key: Option<KeyRef>,
pub background_color: Option<Color>,
pub elevation: Option<f64>,
pub shadow_color: Option<Color>,
pub surface_tint_color: Option<Color>,
pub shape: Option<ShapeBorderRef>,
pub width: Option<f64>,
pub child: Option<WidgetRef>,
pub semantic_label: Option<String>,
pub clip_behavior: Option<Clip>,
}Expand description
A Material Design panel that slides in horizontally from the edge of a
Scaffold to show navigation links in an application.
There is a Material 3 version of this component, NavigationDrawer,
that’s preferred for applications that are configured for Material 3
(see ThemeData::use_material3).
Drawers are typically used with the Scaffold::drawer property. The child of
the drawer is usually a ListView whose first child is a DrawerHeader
that displays status information about the current user. The remaining
drawer children are often constructed with ListTiles, often concluding
with an AboutListTile.
The AppBar automatically displays an appropriate IconButton to show the
Drawer when a Drawer is available in the Scaffold. The Scaffold
automatically handles the edge-swipe gesture to show the drawer.
An open drawer may be closed with a swipe to close gesture, pressing the
escape key, by tapping the scrim, or by calling pop route function such as
Navigator::pop.
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>Sets the color of the Material that holds all of the Drawer’s
contents.
If this is null, then DrawerThemeData::background_color is used. If that
is also null, then it falls back to Material’s default.
elevation: Option<f64>The z-coordinate at which to place this drawer relative to its parent.
This controls the size of the shadow below the drawer.
If this is null, then DrawerThemeData::elevation is used. If that
is also null, then it defaults to 16.0.
shadow_color: Option<Color>The color used to paint a drop shadow under the drawer’s Material,
which reflects the drawer’s elevation.
If null and ThemeData::use_material3 is true then no drop shadow will
be rendered.
If null and ThemeData::use_material3 is false then it will default to
ThemeData::shadow_color.
See also:
Material::shadow_color, which describes how the drop shadow is painted.elevation, which affects how the drop shadow is painted.surface_tint_color, which can be used to indicate elevation through tinting the background color.
surface_tint_color: Option<Color>The color used as a surface tint overlay on the drawer’s background color,
which reflects the drawer’s 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.
To disable this feature, set surface_tint_color to
Colors::TRANSPARENT.
Defaults to Colors::TRANSPARENT.
See also:
Material::surface_tint_color, which describes how the surface tint will be applied to the background color of the drawer.elevation, which affects the opacity of the surface tint.shadow_color, which can be used to indicate elevation through a drop shadow.
shape: Option<ShapeBorderRef>The shape of the drawer.
Defines the drawer’s Material::shape.
If this is null, then DrawerThemeData::shape is used. If that
is also null, then it falls back to Material’s default.
width: Option<f64>The width of the drawer.
If this is null, then DrawerThemeData::width is used. If that is also
null, then it falls back to the Material spec’s default (304.0).
child: Option<WidgetRef>The widget below this widget in the tree.
Typically a ListView.
semantic_label: Option<String>The semantic label of the drawer used by accessibility frameworks to announce screen transitions when the drawer is opened and closed.
If this label is not provided, it will default to
MaterialLocalizations::drawer_label.
clip_behavior: Option<Clip>The clip_behavior argument specifies how to clip the drawer’s
shape.
If the drawer has a shape, it defaults to Clip::HardEdge.
Otherwise, defaults to Clip::None.
Implementations§
Source§impl Drawer
impl Drawer
Sourcepub fn new() -> Drawer
pub fn new() -> Drawer
Creates a Material Design drawer; Dart’s optional named arguments are the setters.
Typically used in the Scaffold::drawer property.
The elevation must be non-negative.
Sourcepub fn background_color(self, background_color: Color) -> Drawer
pub fn background_color(self, background_color: Color) -> Drawer
Dart Drawer(backgroundColor:).
Sourcepub fn shadow_color(self, shadow_color: Color) -> Drawer
pub fn shadow_color(self, shadow_color: Color) -> Drawer
Dart Drawer(shadowColor:).
Sourcepub fn surface_tint_color(self, surface_tint_color: Color) -> Drawer
pub fn surface_tint_color(self, surface_tint_color: Color) -> Drawer
Dart Drawer(surfaceTintColor:).
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> Drawer
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> Drawer
Dart Drawer(shape:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> Drawer
pub fn child<K>(self, child: impl IntoWidget<K>) -> Drawer
Dart Drawer(child:).
Sourcepub fn semantic_label(self, semantic_label: impl Into<String>) -> Drawer
pub fn semantic_label(self, semantic_label: impl Into<String>) -> Drawer
Dart Drawer(semanticLabel:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> Drawer
pub fn clip_behavior(self, clip_behavior: Clip) -> Drawer
Dart Drawer(clipBehavior:).
Trait Implementations§
Source§impl StatelessWidget for Drawer
impl StatelessWidget for Drawer
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§
impl !RefUnwindSafe for Drawer
impl !Send for Drawer
impl !Sync for Drawer
impl !UnwindSafe for Drawer
impl Forget for Drawer
impl Freeze for Drawerwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn ShapeBorder> is !null: Freeze,
PhantomData<RcInner<dyn ShapeBorder>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl Move for Drawer
impl Unpin for Drawer
impl UnsafeUnpin for Drawerwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
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.