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: f64The 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:
highlight_elevation, the default elevation.hover_elevation, the elevation when a pointer is hovering over the button.focus_elevation, the elevation when the button is focused.disabled_elevation, the elevation when the button is disabled.
hover_elevation: f64The 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:
elevation, the default elevation.focus_elevation, the elevation when the button is focused.disabled_elevation, the elevation when the button is disabled.highlight_elevation, the elevation when the button is pressed.
focus_elevation: f64The 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:
elevation, the default elevation.hover_elevation, the elevation when a pointer is hovering over the button.disabled_elevation, the elevation when the button is disabled.highlight_elevation, the elevation when the button is pressed.
highlight_elevation: f64The 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:
elevation, the default elevation.hover_elevation, the elevation when a pointer is hovering over the button.focus_elevation, the elevation when the button is focused.disabled_elevation, the elevation when the button is disabled.
disabled_elevation: f64The elevation for the button’s Material when the button
is not enabled.
Defaults to 0.0. The value is always non-negative.
See also:
elevation, the default elevation.hover_elevation, the elevation when a pointer is hovering over the button.focus_elevation, the elevation when the button is focused.highlight_elevation, the elevation when the button is pressed.
padding: EdgeInsetsGeometryThe internal padding for the button’s child.
visual_density: VisualDensityDefines how compact the button’s layout will be.
See also:
ThemeData::visual_density, which specifies thevisual_densityfor all widgets within aTheme.
constraints: BoxConstraintsDefines the button’s size.
Typically used to constrain the button’s minimum size.
shape: ShapeBorderRefThe 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: DurationDefines the duration of animated changes for shape and
elevation.
The default value is K_THEME_CHANGE_DURATION.
clip_behavior: ClipThe 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: boolTrue 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: MaterialTapTargetSizeConfigures the minimum size of the tap target.
Defaults to MaterialTapTargetSize::Padded.
See also:
MaterialTapTargetSize, for a description of how this affects tap targets.
child: Option<WidgetRef>Typically the button’s label.
enable_feedback: boolWhether 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:
Feedbackfor providing platform-specific feedback to certain actions.
Implementations§
Source§impl RawMaterialButton
impl RawMaterialButton
Sourcepub fn new(on_pressed: Option<Listener>) -> RawMaterialButton
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.
Sourcepub fn key(self, key: KeyRef) -> RawMaterialButton
pub fn key(self, key: KeyRef) -> RawMaterialButton
Dart RawMaterialButton(key:).
Sourcepub fn on_long_press(self, on_long_press: Listener) -> RawMaterialButton
pub fn on_long_press(self, on_long_press: Listener) -> RawMaterialButton
Dart RawMaterialButton(onLongPress:).
Sourcepub fn on_highlight_changed(
self,
on_highlight_changed: ValueChanged<bool>,
) -> RawMaterialButton
pub fn on_highlight_changed( self, on_highlight_changed: ValueChanged<bool>, ) -> RawMaterialButton
Dart RawMaterialButton(onHighlightChanged:).
Sourcepub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> RawMaterialButton
pub fn mouse_cursor(self, mouse_cursor: MouseCursorRef) -> RawMaterialButton
Dart RawMaterialButton(mouseCursor:).
Sourcepub fn text_style(self, text_style: TextStyle) -> RawMaterialButton
pub fn text_style(self, text_style: TextStyle) -> RawMaterialButton
Dart RawMaterialButton(textStyle:).
Sourcepub fn fill_color(self, fill_color: Color) -> RawMaterialButton
pub fn fill_color(self, fill_color: Color) -> RawMaterialButton
Dart RawMaterialButton(fillColor:).
Sourcepub fn focus_color(self, focus_color: Color) -> RawMaterialButton
pub fn focus_color(self, focus_color: Color) -> RawMaterialButton
Dart RawMaterialButton(focusColor:).
Sourcepub fn hover_color(self, hover_color: Color) -> RawMaterialButton
pub fn hover_color(self, hover_color: Color) -> RawMaterialButton
Dart RawMaterialButton(hoverColor:).
Sourcepub fn highlight_color(self, highlight_color: Color) -> RawMaterialButton
pub fn highlight_color(self, highlight_color: Color) -> RawMaterialButton
Dart RawMaterialButton(highlightColor:).
Sourcepub fn splash_color(self, splash_color: Color) -> RawMaterialButton
pub fn splash_color(self, splash_color: Color) -> RawMaterialButton
Dart RawMaterialButton(splashColor:).
Sourcepub fn elevation(self, elevation: f64) -> RawMaterialButton
pub fn elevation(self, elevation: f64) -> RawMaterialButton
Dart RawMaterialButton(elevation:).
Sourcepub fn focus_elevation(self, focus_elevation: f64) -> RawMaterialButton
pub fn focus_elevation(self, focus_elevation: f64) -> RawMaterialButton
Dart RawMaterialButton(focusElevation:).
Sourcepub fn hover_elevation(self, hover_elevation: f64) -> RawMaterialButton
pub fn hover_elevation(self, hover_elevation: f64) -> RawMaterialButton
Dart RawMaterialButton(hoverElevation:).
Sourcepub fn highlight_elevation(self, highlight_elevation: f64) -> RawMaterialButton
pub fn highlight_elevation(self, highlight_elevation: f64) -> RawMaterialButton
Dart RawMaterialButton(highlightElevation:).
Sourcepub fn disabled_elevation(self, disabled_elevation: f64) -> RawMaterialButton
pub fn disabled_elevation(self, disabled_elevation: f64) -> RawMaterialButton
Dart RawMaterialButton(disabledElevation:).
Sourcepub fn padding(
self,
padding: impl Into<EdgeInsetsGeometry>,
) -> RawMaterialButton
pub fn padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> RawMaterialButton
Dart RawMaterialButton(padding:).
Sourcepub fn visual_density(self, visual_density: VisualDensity) -> RawMaterialButton
pub fn visual_density(self, visual_density: VisualDensity) -> RawMaterialButton
Dart RawMaterialButton(visualDensity:).
Sourcepub fn constraints(self, constraints: BoxConstraints) -> RawMaterialButton
pub fn constraints(self, constraints: BoxConstraints) -> RawMaterialButton
Dart RawMaterialButton(constraints:).
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> RawMaterialButton
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> RawMaterialButton
Dart RawMaterialButton(shape:).
Sourcepub fn animation_duration(
self,
animation_duration: Duration,
) -> RawMaterialButton
pub fn animation_duration( self, animation_duration: Duration, ) -> RawMaterialButton
Dart RawMaterialButton(animationDuration:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> RawMaterialButton
pub fn clip_behavior(self, clip_behavior: Clip) -> RawMaterialButton
Dart RawMaterialButton(clipBehavior:).
Sourcepub fn focus_node(self, focus_node: FocusNodeRef) -> RawMaterialButton
pub fn focus_node(self, focus_node: FocusNodeRef) -> RawMaterialButton
Dart RawMaterialButton(focusNode:).
Sourcepub fn autofocus(self, autofocus: bool) -> RawMaterialButton
pub fn autofocus(self, autofocus: bool) -> RawMaterialButton
Dart RawMaterialButton(autofocus:).
Sourcepub fn material_tap_target_size(
self,
material_tap_target_size: MaterialTapTargetSize,
) -> RawMaterialButton
pub fn material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> RawMaterialButton
Dart RawMaterialButton(materialTapTargetSize:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> RawMaterialButton
pub fn child<K>(self, child: impl IntoWidget<K>) -> RawMaterialButton
Dart RawMaterialButton(child:).
Sourcepub fn enable_feedback(self, enable_feedback: bool) -> RawMaterialButton
pub fn enable_feedback(self, enable_feedback: bool) -> RawMaterialButton
Dart RawMaterialButton(enableFeedback:).
Sourcepub fn enabled(&self) -> bool
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
impl Debug for RawMaterialButton
Source§impl StatefulWidget for RawMaterialButton
impl StatefulWidget for RawMaterialButton
Source§type State = RawMaterialButtonState
type State = RawMaterialButtonState
Source§fn create_state(&self) -> RawMaterialButtonState
fn create_state(&self) -> RawMaterialButtonState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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 as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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 RawMaterialButtonwhere
*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 RawMaterialButtonwhere
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 RawMaterialButtonwhere
*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> 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<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.