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>
impl<Msg: Clone + 'static> MaterialBanner<Msg>
Sourcepub fn new(content: impl Into<String>) -> Self
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.
Sourcepub fn with_content(content: impl Widget<Msg> + 'static) -> Self
pub fn with_content(content: impl Widget<Msg> + 'static) -> Self
The same, with a widget in place of the text.
Sourcepub fn action(self, action: impl Widget<Msg> + 'static) -> Self
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).
Sourcepub fn force_actions_below(self, force: bool) -> Self
pub fn force_actions_below(self, force: bool) -> Self
Puts the actions on a line of their own even when there is only one.
Sourcepub fn content_text_style(self, style: TextStyle) -> Self
pub fn content_text_style(self, style: TextStyle) -> Self
What the message is set in. bodyMedium by default.
Sourcepub fn background(self, color: Color) -> Self
pub fn background(self, color: Color) -> Self
The banner’s colour. A low container tone by default.
Sourcepub fn surface_tint(self, color: Color) -> Self
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).
Sourcepub fn shadow_color(self, color: Color) -> Self
pub fn shadow_color(self, color: Color) -> Self
The shadow’s colour. Unset, there is none.
Sourcepub fn divider_color(self, color: Color) -> Self
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.
Sourcepub fn elevation(self, elevation: f32) -> Self
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.
Sourcepub fn leading_padding(self, padding: Insets) -> Self
pub fn leading_padding(self, padding: Insets) -> Self
What the leading slot is held off the message by.
Sourcepub fn min_action_bar_height(self, height: f32) -> Self
pub fn min_action_bar_height(self, height: f32) -> Self
The shortest the actions bar gets. 52 by default.
Sourcepub fn build(self) -> Box<dyn Widget<Msg>>
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.