Skip to main content

MaterialBanner

Struct MaterialBanner 

Source
pub struct MaterialBanner<Msg = Callback> { /* private fields */ }
Expand description

A message across the top of the screen with the actions that answer it.

It sits in the flow, not over it: a banner is put above the content it is about, usually as the first child of a screen’s column. Nothing hides it on a timer, which is the whole difference from a snack bar — an action does.

Implementations§

Source§

impl<Msg: Clone + 'static> MaterialBanner<Msg>

Source

pub fn new(content: impl Into<String>) -> Self

A banner saying content. Add at least one action: a banner stays until one is taken, and the reference makes them required for that reason.

Source

pub fn with_content(content: impl Widget<Msg> + 'static) -> Self

The same, with a widget in place of the text.

Source

pub fn leading(self, leading: impl Widget<Msg> + 'static) -> Self

A glyph before the message.

Source

pub fn action(self, action: impl Widget<Msg> + 'static) -> Self

Adds an action. One action sits on the message’s own line; two or more take a line of their own (banner.dart:348).

Source

pub fn force_actions_below(self, force: bool) -> Self

Puts the actions on a line of their own even when there is only one.

Source

pub fn content_text_style(self, style: TextStyle) -> Self

What the message is set in. bodyMedium by default.

Source

pub fn background(self, color: Color) -> Self

The banner’s colour. A low container tone by default.

Source

pub fn surface_tint(self, color: Color) -> Self

What the surface is tinted towards for its elevation. Unset, nothing is — the reference’s Material 3 answer (banner.dart:513).

Source

pub fn shadow_color(self, color: Color) -> Self

The shadow’s colour. Unset, there is none.

Source

pub fn divider_color(self, color: Color) -> Self

The rule along the bottom, which is drawn only when the banner is flat — see Self::elevation.

Source

pub fn elevation(self, elevation: f32) -> Self

How far off the page it sits. 0 by default — see BANNER_ELEVATION.

It decides two other things, which is why it is worth naming: a banner off the page keeps a 10-pixel margin under it so its shadow has room, and a banner flat on the page draws a rule along its bottom edge instead (banner.dart:425). Height or a line, never both — the same either-or Card makes between a shadow and a hairline.

Source

pub fn padding(self, padding: Insets) -> Self

The padding around the message row.

Source

pub fn margin(self, margin: Insets) -> Self

The margin around the banner.

Source

pub fn leading_padding(self, padding: Insets) -> Self

What the leading slot is held off the message by.

Source

pub fn min_action_bar_height(self, height: f32) -> Self

The shortest the actions bar gets. 52 by default.

Source

pub fn build(self) -> Box<dyn Widget<Msg>>

Assembles the banner.

Deferred to a ThemeBuilder: whether the actions sit on the message’s line decides which children exist and in what order, and the padding and the rule are the theme’s to answer, so the composition cannot happen before the theme is known.

Auto Trait Implementations§

§

impl<Msg = Callback> !RefUnwindSafe for MaterialBanner<Msg>

§

impl<Msg = Callback> !Send for MaterialBanner<Msg>

§

impl<Msg = Callback> !Sync for MaterialBanner<Msg>

§

impl<Msg = Callback> !UnwindSafe for MaterialBanner<Msg>

§

impl<Msg> Freeze for MaterialBanner<Msg>
where Option<Box<dyn Widget<Msg>>>: Freeze, Vec<Box<dyn Widget<Msg>>>: Freeze,

§

impl<Msg> Unpin for MaterialBanner<Msg>
where Option<Box<dyn Widget<Msg>>>: Unpin, Vec<Box<dyn Widget<Msg>>>: Unpin,

§

impl<Msg> UnsafeUnpin for MaterialBanner<Msg>
where Option<Box<dyn Widget<Msg>>>: UnsafeUnpin, Vec<Box<dyn Widget<Msg>>>: UnsafeUnpin,

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<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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
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.