Skip to main content

MaterialButton

Struct MaterialButton 

Source
pub struct MaterialButton {
Show 32 fields pub key: Option<KeyRef>, pub on_pressed: Option<Listener>, pub on_long_press: Option<Listener>, pub on_highlight_changed: Option<ValueChanged<bool>>, pub mouse_cursor: Option<MouseCursorRef>, pub text_theme: Option<ButtonTextTheme>, pub text_color: Option<Color>, pub disabled_text_color: Option<Color>, pub color: Option<Color>, pub disabled_color: Option<Color>, pub splash_color: Option<Color>, pub focus_color: Option<Color>, pub hover_color: Option<Color>, pub highlight_color: Option<Color>, pub elevation: Option<f64>, pub hover_elevation: Option<f64>, pub focus_elevation: Option<f64>, pub highlight_elevation: Option<f64>, pub disabled_elevation: Option<f64>, pub color_brightness: Option<Brightness>, pub child: Option<WidgetRef>, pub padding: Option<EdgeInsetsGeometry>, pub visual_density: Option<VisualDensity>, pub shape: Option<ShapeBorderRef>, pub clip_behavior: Clip, pub focus_node: Option<FocusNodeRef>, pub autofocus: bool, pub animation_duration: Option<Duration>, pub material_tap_target_size: Option<MaterialTapTargetSize>, pub min_width: Option<f64>, pub height: Option<f64>, pub enable_feedback: bool,
}
Expand description

A Material Design button.

To create a custom Material button consider using TextButton, ElevatedButton, or OutlinedButton.

The elevation, hover_elevation, focus_elevation, highlight_elevation and disabled_elevation arguments must be non-negative, if specified.

Fields§

§key: Option<KeyRef>§on_pressed: Option<Listener>

The callback that is called when the button is tapped or otherwise activated.

If this callback and on_long_press are null, then the button will be disabled.

§on_long_press: Option<Listener>

The callback that is called when the button is long-pressed.

§on_highlight_changed: Option<ValueChanged<bool>>

Called by the underlying InkWell widget’s onHighlightChanged callback.

§mouse_cursor: Option<MouseCursorRef>

The cursor for a mouse pointer when it enters or is hovering over the button.

§text_theme: Option<ButtonTextTheme>

Defines the button’s base colors, and the defaults for the button’s minimum size, internal padding, and shape.

§text_color: Option<Color>

The color to use for this button’s text.

§disabled_text_color: Option<Color>

The color to use for this button’s text when the button is disabled.

§color: Option<Color>

The button’s fill color while it is in its default (unpressed, enabled) state.

§disabled_color: Option<Color>

The fill color of the button when the button is disabled.

§splash_color: Option<Color>

The splash color of the button’s InkWell.

§focus_color: Option<Color>

The fill color of the button’s Material when it has the input focus.

§hover_color: Option<Color>

The fill color of the button’s Material when a pointer is hovering over it.

§highlight_color: Option<Color>

The highlight color of the button’s InkWell.

§elevation: Option<f64>

The z-coordinate at which to place this button relative to its parent.

§hover_elevation: Option<f64>

The elevation for the button’s Material when the button is enabled and a pointer is hovering over it.

§focus_elevation: Option<f64>

The elevation for the button’s Material when the button is enabled and has the input focus.

§highlight_elevation: Option<f64>

The elevation for the button’s Material relative to its parent when the button is enabled and pressed.

§disabled_elevation: Option<f64>

The elevation for the button’s Material relative to its parent when the button is not enabled.

§color_brightness: Option<Brightness>

The theme brightness to use for this button.

§child: Option<WidgetRef>

The button’s label.

§padding: Option<EdgeInsetsGeometry>

The internal padding for the button’s child.

§visual_density: Option<VisualDensity>

Defines how compact the button’s layout will be.

§shape: Option<ShapeBorderRef>

The shape of the button’s Material.

§clip_behavior: Clip

How to clip the button’s Material.

§focus_node: Option<FocusNodeRef>

The focus node of the button.

§autofocus: bool

Whether the button will be selected as the initial focus when no other node in its scope is currently focused.

§animation_duration: Option<Duration>

The duration of animated changes for shape and elevation.

§material_tap_target_size: Option<MaterialTapTargetSize>

Configures the minimum size of the tap target.

§min_width: Option<f64>

The smallest horizontal extent that the button will occupy.

§height: Option<f64>

The vertical extent of the button.

§enable_feedback: bool

Whether detected gestures should provide acoustic and/or haptic feedback.

Implementations§

Source§

impl MaterialButton

Source

pub fn new(on_pressed: Option<Listener>) -> MaterialButton

Creates a Material Design button; Dart’s optional named arguments are the setters.

Source

pub fn enabled(&self) -> bool

Whether the button is enabled or disabled.

Source

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

Dart MaterialButton(key:).

Source

pub fn on_long_press(self, on_long_press: Listener) -> MaterialButton

Dart MaterialButton(onLongPress:).

Source

pub fn on_highlight_changed( self, on_highlight_changed: ValueChanged<bool>, ) -> MaterialButton

Dart MaterialButton(onHighlightChanged:).

Source

pub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> MaterialButton

Dart MaterialButton(mouseCursor:).

Source

pub fn text_theme(self, text_theme: ButtonTextTheme) -> MaterialButton

Dart MaterialButton(textTheme:).

Source

pub fn text_color(self, text_color: Color) -> MaterialButton

Dart MaterialButton(textColor:).

Source

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

Dart MaterialButton(disabledTextColor:).

Source

pub fn color(self, color: Color) -> MaterialButton

Dart MaterialButton(color:).

Source

pub fn disabled_color(self, disabled_color: Color) -> MaterialButton

Dart MaterialButton(disabledColor:).

Source

pub fn splash_color(self, splash_color: Color) -> MaterialButton

Dart MaterialButton(splashColor:).

Source

pub fn focus_color(self, focus_color: Color) -> MaterialButton

Dart MaterialButton(focusColor:).

Source

pub fn hover_color(self, hover_color: Color) -> MaterialButton

Dart MaterialButton(hoverColor:).

Source

pub fn highlight_color(self, highlight_color: Color) -> MaterialButton

Dart MaterialButton(highlightColor:).

Source

pub fn color_brightness(self, color_brightness: Brightness) -> MaterialButton

Dart MaterialButton(colorBrightness:).

Source

pub fn elevation(self, elevation: f64) -> MaterialButton

Dart MaterialButton(elevation:).

Source

pub fn focus_elevation(self, focus_elevation: f64) -> MaterialButton

Dart MaterialButton(focusElevation:).

Source

pub fn hover_elevation(self, hover_elevation: f64) -> MaterialButton

Dart MaterialButton(hoverElevation:).

Source

pub fn highlight_elevation(self, highlight_elevation: f64) -> MaterialButton

Dart MaterialButton(highlightElevation:).

Source

pub fn disabled_elevation(self, disabled_elevation: f64) -> MaterialButton

Dart MaterialButton(disabledElevation:).

Source

pub fn padding(self, padding: impl Into<EdgeInsetsGeometry>) -> MaterialButton

Dart MaterialButton(padding:).

Source

pub fn visual_density(self, visual_density: VisualDensity) -> MaterialButton

Dart MaterialButton(visualDensity:).

Source

pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> MaterialButton

Dart MaterialButton(shape:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> MaterialButton

Dart MaterialButton(clipBehavior:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> MaterialButton

Dart MaterialButton(focusNode:).

Source

pub fn autofocus(self, autofocus: bool) -> MaterialButton

Dart MaterialButton(autofocus:).

Source

pub fn animation_duration(self, animation_duration: Duration) -> MaterialButton

Dart MaterialButton(animationDuration:).

Source

pub fn material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> MaterialButton

Dart MaterialButton(materialTapTargetSize:).

Source

pub fn min_width(self, min_width: f64) -> MaterialButton

Dart MaterialButton(minWidth:).

Source

pub fn height(self, height: f64) -> MaterialButton

Dart MaterialButton(height:).

Source

pub fn enable_feedback(self, enable_feedback: bool) -> MaterialButton

Dart MaterialButton(enableFeedback:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> MaterialButton

Dart MaterialButton(child:).

Trait Implementations§

Source§

impl Debug for MaterialButton

Source§

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

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

impl StatelessWidget for MaterialButton

Source§

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

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 build(&self, app: &mut App, context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

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

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

§

impl !Send for MaterialButton

§

impl !Sync for MaterialButton

§

impl !UnwindSafe for MaterialButton

§

impl Forget for MaterialButton

§

impl Freeze for MaterialButton
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, *const RcInner<dyn MouseCursor> is !null: Freeze, PhantomData<RcInner<dyn MouseCursor>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze,

§

impl Move for MaterialButton

§

impl Unpin for MaterialButton
where Rc<dyn Key>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, Rc<dyn MouseCursor>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn ShapeBorder>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin,

§

impl UnsafeUnpin for MaterialButton
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, *const RcInner<dyn MouseCursor> is !null: UnsafeUnpin, PhantomData<RcInner<dyn MouseCursor>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: 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> 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<StatelessKind> for W
where W: StatelessWidget,

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, 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>