pub struct SnackbarMessage<State: 'static> { /* private fields */ }Expand description
A declarative snackbar message. Built via snackbar, shown via
SnackbarController::show. See the module docs.
Implementations§
Source§impl<State: 'static> SnackbarMessage<State>
impl<State: 'static> SnackbarMessage<State>
Sourcepub fn action<F: Fn(&mut State) + 'static>(
self,
label: impl Into<String>,
on_action: F,
) -> Self
pub fn action<F: Fn(&mut State) + 'static>( self, label: impl Into<String>, on_action: F, ) -> Self
Attach a single action button, labeled label. Pressing it fires
on_action and dismisses the message immediately — Flutter’s own
stock SnackBarAction behavior (flutter/material/snack_bar.dart‘s
_SnackBarActionState._handlePressed, which always closes the
snackbar right after invoking its callback); this crate’s own upstream
reference has no action-press dismiss logic of its own to port (its
onAction callback is the only thing it fires — see the module docs’
Queue/replace rule for the parallel gap in that file), so this
follows the wider platform convention instead.
Sourcepub fn duration(self, duration: Duration) -> Self
pub fn duration(self, duration: Duration) -> Self
Override the auto-dismiss hold duration. [DEFAULT_DURATION] (4s)
unless set.
Sourcepub fn dismissible(self) -> Self
pub fn dismissible(self) -> Self
Show a close (×) icon that dismisses the message without firing
on_action. Off unless called — the upstream reference has no close
affordance at all (see the module docs).
Auto Trait Implementations§
impl<State> !RefUnwindSafe for SnackbarMessage<State>
impl<State> !Send for SnackbarMessage<State>
impl<State> !Sync for SnackbarMessage<State>
impl<State> !UnwindSafe for SnackbarMessage<State>
impl<State> Freeze for SnackbarMessage<State>
impl<State> Unpin for SnackbarMessage<State>
impl<State> UnsafeUnpin for SnackbarMessage<State>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.