Skip to main content

RawMaterialButton

Struct RawMaterialButton 

Source
pub struct RawMaterialButton {
Show 27 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_style: Option<TextStyle>, pub fill_color: Option<Color>, pub focus_color: Option<Color>, pub hover_color: Option<Color>, pub highlight_color: Option<Color>, pub splash_color: Option<Color>, pub elevation: f64, pub hover_elevation: f64, pub focus_elevation: f64, pub highlight_elevation: f64, pub disabled_elevation: f64, pub padding: EdgeInsetsGeometry, pub visual_density: VisualDensity, pub constraints: BoxConstraints, pub shape: ShapeBorderRef, pub animation_duration: Duration, pub clip_behavior: Clip, pub focus_node: Option<FocusNodeRef>, pub autofocus: bool, pub material_tap_target_size: MaterialTapTargetSize, pub child: Option<WidgetRef>, pub enable_feedback: bool,
}
Expand description

Creates a button based on Semantics, Material, and InkWell widgets.

This class does not use the current Theme or ButtonTheme to compute default values for unspecified parameters. It’s intended to be used for custom Material buttons that optionally incorporate defaults from the themes or from app-specific sources.

This class is planned to be deprecated in a future release, see ButtonStyleButton, the base class of ElevatedButton, FilledButton, OutlinedButton and TextButton.

See also:

  • ElevatedButton, a filled button whose material elevates when pressed.
  • FilledButton, a filled button that doesn’t elevate when pressed.
  • FilledButton.tonal, a filled button variant that uses a secondary fill color.
  • OutlinedButton, a button with an outlined border and no fill color.
  • TextButton, a button with no outline or fill color.

Fields§

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

Called when the button is tapped or otherwise activated.

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

See also:

  • enabled, which is true if the button is enabled.
§on_long_press: Option<Listener>

Called when the button is long-pressed.

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

See also:

  • enabled, which is true if the button is enabled.
§on_highlight_changed: Option<ValueChanged<bool>>

Called by the underlying InkWell widget’s InkWell.on_highlight_changed callback.

If on_pressed changes from null to non-null while a gesture is ongoing, this can fire during the build phase (in which case calling State::set_state is not allowed).

§mouse_cursor: Option<MouseCursorRef>

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

If mouse_cursor is a WidgetStateMouseCursor, WidgetStateProperty::resolve is used for the following WidgetStates:

If this property is null, WidgetStateMouseCursor::adaptive_clickable will be used.

§text_style: Option<TextStyle>

Defines the default text style, with Material::text_style, for the button’s child.

If TextStyle.color is a WidgetStateProperty<Color>, WidgetStateProperty::resolve is used for the following WidgetStates:

§fill_color: Option<Color>

The color of the button’s Material.

§focus_color: Option<Color>

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

§hover_color: Option<Color>

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

§highlight_color: Option<Color>

The highlight color for the button’s InkWell.

§splash_color: Option<Color>

The splash color for the button’s InkWell.

§elevation: f64

The elevation for the button’s Material when the button is enabled but not pressed.

Defaults to 2.0. The value is always non-negative.

See also:

§hover_elevation: f64

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

Defaults to 4.0. The value is always non-negative.

If the button is enabled, and being pressed (in the highlighted state), then the highlight_elevation take precedence over the hover_elevation.

See also:

§focus_elevation: f64

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

Defaults to 4.0. The value is always non-negative.

If the button is enabled, and being pressed (in the highlighted state), or a mouse cursor is hovering over the button, then the hover_elevation and highlight_elevation take precedence over the focus_elevation.

See also:

§highlight_elevation: f64

The elevation for the button’s Material when the button is enabled and pressed.

Defaults to 8.0. The value is always non-negative.

See also:

§disabled_elevation: f64

The elevation for the button’s Material when the button is not enabled.

Defaults to 0.0. The value is always non-negative.

See also:

§padding: EdgeInsetsGeometry

The internal padding for the button’s child.

§visual_density: VisualDensity

Defines how compact the button’s layout will be.

See also:

  • ThemeData::visual_density, which specifies the visual_density for all widgets within a Theme.
§constraints: BoxConstraints

Defines the button’s size.

Typically used to constrain the button’s minimum size.

§shape: ShapeBorderRef

The shape of the button’s Material.

The button’s highlight and splash are clipped to this shape. If the button has an elevation, then its drop shadow is defined by this shape.

If shape is a WidgetStateOutlinedBorder, WidgetStateProperty::resolve is used for the following WidgetStates:

§animation_duration: Duration

Defines the duration of animated changes for shape and elevation.

The default value is K_THEME_CHANGE_DURATION.

§clip_behavior: Clip

The content will be clipped (or not) according to this option.

Defaults to Clip::None.

§focus_node: Option<FocusNodeRef>

An optional focus node to use as the focus node for this widget.

See Focus::focus_node.

§autofocus: bool

True if this widget will be selected as the initial focus when no other node in its scope is currently focused.

See Focus::autofocus.

§material_tap_target_size: MaterialTapTargetSize

Configures the minimum size of the tap target.

Defaults to MaterialTapTargetSize::Padded.

See also:

§child: Option<WidgetRef>

Typically the button’s label.

§enable_feedback: bool

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

For example, on Android a tap will produce a clicking sound and a long-press will produce a short vibration, when feedback is enabled.

See also:

  • Feedback for providing platform-specific feedback to certain actions.

Implementations§

Source§

impl RawMaterialButton

Source

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

Create a button based on Semantics, Material, and InkWell widgets.

The elevation, focus_elevation, hover_elevation, highlight_elevation, and disabled_elevation parameters must be non-negative.

Source

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

Dart RawMaterialButton(key:).

Source

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

Dart RawMaterialButton(onLongPress:).

Source

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

Dart RawMaterialButton(onHighlightChanged:).

Source

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

Dart RawMaterialButton(mouseCursor:).

Source

pub fn text_style(self, text_style: TextStyle) -> RawMaterialButton

Dart RawMaterialButton(textStyle:).

Source

pub fn fill_color(self, fill_color: Color) -> RawMaterialButton

Dart RawMaterialButton(fillColor:).

Source

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

Dart RawMaterialButton(focusColor:).

Source

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

Dart RawMaterialButton(hoverColor:).

Source

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

Dart RawMaterialButton(highlightColor:).

Source

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

Dart RawMaterialButton(splashColor:).

Source

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

Dart RawMaterialButton(elevation:).

Source

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

Dart RawMaterialButton(focusElevation:).

Source

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

Dart RawMaterialButton(hoverElevation:).

Source

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

Dart RawMaterialButton(highlightElevation:).

Source

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

Dart RawMaterialButton(disabledElevation:).

Source

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

Dart RawMaterialButton(padding:).

Source

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

Dart RawMaterialButton(visualDensity:).

Source

pub fn constraints(self, constraints: BoxConstraints) -> RawMaterialButton

Dart RawMaterialButton(constraints:).

Source

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

Dart RawMaterialButton(shape:).

Source

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

Dart RawMaterialButton(animationDuration:).

Source

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

Dart RawMaterialButton(clipBehavior:).

Source

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

Dart RawMaterialButton(focusNode:).

Source

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

Dart RawMaterialButton(autofocus:).

Source

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

Dart RawMaterialButton(materialTapTargetSize:).

Source

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

Dart RawMaterialButton(child:).

Source

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

Dart RawMaterialButton(enableFeedback:).

Source

pub fn enabled(&self) -> bool

Whether the button is enabled or disabled.

Buttons are disabled by default. To enable a button, set its on_pressed or on_long_press properties to a non-null value.

Trait Implementations§

Source§

impl Debug for RawMaterialButton

Source§

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

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

impl StatefulWidget for RawMaterialButton

Source§

type State = RawMaterialButtonState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> RawMaterialButtonState

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 RawMaterialButton

§

impl !Send for RawMaterialButton

§

impl !Sync for RawMaterialButton

§

impl !UnwindSafe for RawMaterialButton

§

impl Forget for RawMaterialButton

§

impl Freeze for RawMaterialButton
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, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const RcInner<Paint> is !null: Freeze, PhantomData<RcInner<Paint>>: Freeze, PhantomData<Shadow>: Freeze, PhantomData<FontFeature>: Freeze, PhantomData<FontVariation>: 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, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for RawMaterialButton

§

impl Unpin for RawMaterialButton
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, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, *const u8 is !null: Unpin, Rc<Paint>: Unpin, Rc<dyn ShapeBorder>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for RawMaterialButton
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, &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, *const RcInner<Paint> is !null: UnsafeUnpin, PhantomData<RcInner<Paint>>: UnsafeUnpin, PhantomData<Shadow>: UnsafeUnpin, PhantomData<FontFeature>: UnsafeUnpin, PhantomData<FontVariation>: 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, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: 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<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, 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>