Skip to main content

SnackBarAction

Struct SnackBarAction 

Source
pub struct SnackBarAction {
    pub key: Option<KeyRef>,
    pub text_color: Option<AnyColor>,
    pub background_color: Option<AnyColor>,
    pub disabled_text_color: Option<Color>,
    pub disabled_background_color: Option<Color>,
    pub label: String,
    pub on_pressed: VoidCallback,
}
Expand description

A button for a SnackBar, known as an “action”.

Snack bar actions are always enabled. Instead of disabling a snack bar action, avoid including it in the snack bar in the first place.

Snack bar actions can only be pressed once. Subsequent presses are ignored.

See also:

Fields§

§key: Option<KeyRef>§text_color: Option<AnyColor>

The button label color. If not provided, defaults to SnackBarThemeData::action_text_color.

If text_color is a WidgetStateColor, then the text color will be resolved against the set of WidgetStates that the action text is in, thus allowing for different colors for states such as pressed, hovered and others.

§background_color: Option<AnyColor>

The button background fill color. If not provided, defaults to SnackBarThemeData::action_background_color.

If background_color is a WidgetStateColor, then the text color will be resolved against the set of WidgetStates that the action text is in, thus allowing for different colors for the states.

§disabled_text_color: Option<Color>

The button disabled label color. This color is shown after the SnackBarAction is dismissed.

§disabled_background_color: Option<Color>

The button disabled background color. This color is shown after the SnackBarAction is dismissed.

If not provided, defaults to SnackBarThemeData::disabled_action_background_color.

§label: String

The button label.

§on_pressed: VoidCallback

The callback to be called when the button is pressed.

This callback will be called at most once each time this action is displayed in a SnackBar.

Implementations§

Source§

impl SnackBarAction

Source

pub fn new( label: impl Into<String>, on_pressed: impl Fn(&mut App) + 'static, ) -> SnackBarAction

Creates an action for a SnackBar; Dart’s optional arguments are the setters.

Source

pub fn key(self, key: KeyRef) -> SnackBarAction

Dart SnackBarAction(key:).

Source

pub fn text_color(self, text_color: impl Into<AnyColor>) -> SnackBarAction

Dart SnackBarAction(textColor:).

Source

pub fn disabled_text_color(self, disabled_text_color: Color) -> SnackBarAction

Dart SnackBarAction(disabledTextColor:).

Source

pub fn background_color( self, background_color: impl Into<AnyColor>, ) -> SnackBarAction

Dart SnackBarAction(backgroundColor:).

Source

pub fn disabled_background_color( self, disabled_background_color: Color, ) -> SnackBarAction

Dart SnackBarAction(disabledBackgroundColor:).

Trait Implementations§

Source§

impl Clone for SnackBarAction

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SnackBarAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for SnackBarAction

Source§

type State = SnackBarActionState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> SnackBarActionState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for SnackBarAction

§

impl !Send for SnackBarAction

§

impl !Sync for SnackBarAction

§

impl !UnwindSafe for SnackBarAction

§

impl Forget for SnackBarAction

§

impl Freeze for SnackBarAction
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze,

§

impl Move for SnackBarAction

§

impl Unpin for SnackBarAction
where Rc<dyn Key>: Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(&mut App)>: Unpin,

§

impl UnsafeUnpin for SnackBarAction
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>