pub struct FloatingActionButton {Show 27 fields
pub key: Option<KeyRef>,
pub child: Option<WidgetRef>,
pub tooltip: Option<String>,
pub foreground_color: Option<Color>,
pub background_color: Option<Color>,
pub focus_color: Option<Color>,
pub hover_color: Option<Color>,
pub splash_color: Option<Color>,
pub hero_tag: Option<Rc<dyn AnyEq>>,
pub on_pressed: Option<Listener>,
pub mouse_cursor: Option<MouseCursorRef>,
pub elevation: Option<f64>,
pub focus_elevation: Option<f64>,
pub hover_elevation: Option<f64>,
pub highlight_elevation: Option<f64>,
pub disabled_elevation: Option<f64>,
pub mini: bool,
pub shape: Option<ShapeBorderRef>,
pub clip_behavior: Clip,
pub is_extended: bool,
pub focus_node: Option<FocusNodeRef>,
pub autofocus: bool,
pub material_tap_target_size: Option<MaterialTapTargetSize>,
pub enable_feedback: Option<bool>,
pub extended_icon_label_spacing: Option<f64>,
pub extended_padding: Option<EdgeInsetsGeometry>,
pub extended_text_style: Option<TextStyle>,
/* private fields */
}Expand description
A Material Design floating action button.
A floating action button is a circular icon button that hovers over content
to promote a primary action in the application. Floating action buttons are
most commonly used in the Scaffold::floating_action_button field.
Use at most a single floating action button per screen. Floating action
buttons should be used for positive actions such as “create”, “share”, or
“navigate”. (If more than one floating action button is used within a
Route, then make sure that each button has a unique hero_tag,
otherwise an exception will be thrown.)
If the on_pressed callback is null, then the button will be disabled
and will not react to touch. It is highly discouraged to disable a floating
action button as there is no indication to the user that the button is
disabled. Consider changing the background_color if disabling
the floating action button.
See also:
Scaffold, in which floating action buttons typically live.ElevatedButton, a filled button whose material elevates when pressed.- https://material.io/design/components/buttons-floating-action-button.html
- https://m3.material.io/components/floating-action-button
Fields§
§key: Option<KeyRef>§child: Option<WidgetRef>The widget below this widget in the tree.
Typically an Icon.
tooltip: Option<String>Text that describes the action that will occur when the button is pressed.
This text is displayed when the user long-presses on the button and is used for accessibility.
foreground_color: Option<Color>The default foreground color for icons and text within the button.
If this property is null, then the ambient
FloatingActionButtonThemeData::foreground_color is used. If that property is also
null, then the ColorScheme::on_primary_container color of ThemeData::color_scheme
is used. If ThemeData::use_material3 is set to false, then the
ColorScheme::on_secondary color of ThemeData::color_scheme is used.
background_color: Option<Color>The button’s background color.
If this property is null, then the ambient
FloatingActionButtonThemeData::background_color is used. If that property is also
null, then the ColorScheme::primary_container color of ThemeData::color_scheme
is used. If ThemeData::use_material3 is set to false, then the
ColorScheme::secondary color of ThemeData::color_scheme is used.
focus_color: Option<Color>The color to use for filling the button when the button has input focus.
In Material3, defaults to ColorScheme::on_primary_container with opacity 0.1.
In Material 2, it defaults to ThemeData::focus_color for the current theme.
hover_color: Option<Color>The color to use for filling the button when the button has a pointer hovering over it.
Defaults to ThemeData::hover_color for the current theme in Material 2. In
Material 3, defaults to ColorScheme::on_primary_container with opacity 0.08.
splash_color: Option<Color>The splash color for this FloatingActionButton’s InkWell.
If null, FloatingActionButtonThemeData::splash_color is used, if that is
null, ThemeData::splash_color is used in Material 2;
ColorScheme::on_primary_container with opacity 0.1 is used in Material 3.
hero_tag: Option<Rc<dyn AnyEq>>The tag to apply to the button’s Hero widget.
Defaults to a tag that matches other floating action buttons.
Set this to null explicitly if you don’t want the floating action button to have a hero tag.
If this is not explicitly set, then there can only be one
FloatingActionButton per route (that is, per screen), since otherwise
there would be a tag conflict (multiple heroes on one route can’t have the
same tag). The Material Design specification recommends only using one
floating action button per screen.
on_pressed: Option<Listener>The callback that is called when the button is tapped or otherwise activated.
If this is set to null, the button will be disabled.
mouse_cursor: Option<MouseCursorRef>The cursor for a mouse pointer when it enters or is hovering over the button.
If this property is null, FloatingActionButtonThemeData::mouse_cursor is used.
If that is null, WidgetStateMouseCursor::adaptive_clickable will be used.
elevation: Option<f64>The z-coordinate at which to place this button relative to its parent.
This controls the size of the shadow below the floating action button.
Defaults to 6, the appropriate elevation for floating action buttons. The value is always non-negative.
See also:
highlight_elevation, the elevation when the button is pressed.disabled_elevation, the elevation when the button is disabled.
focus_elevation: Option<f64>The z-coordinate at which to place this button relative to its parent when the button has the input focus.
This controls the size of the shadow below the floating action button.
Defaults to 8, the appropriate elevation for floating action buttons while they have focus. The value is always non-negative.
See also:
elevation, the default elevation.highlight_elevation, the elevation when the button is pressed.disabled_elevation, the elevation when the button is disabled.
hover_elevation: Option<f64>The z-coordinate at which to place this button relative to its parent when the button is enabled and has a pointer hovering over it.
This controls the size of the shadow below the floating action button.
Defaults to 8, the appropriate elevation for floating action buttons while they have a pointer hovering over them. The value is always non-negative.
See also:
elevation, the default elevation.highlight_elevation, the elevation when the button is pressed.disabled_elevation, the elevation when the button is disabled.
highlight_elevation: Option<f64>The z-coordinate at which to place this button relative to its parent when the user is touching the button.
This controls the size of the shadow below the floating action button.
Defaults to 12, the appropriate elevation for floating action buttons while they are being touched. The value is always non-negative.
See also:
elevation, the default elevation.
disabled_elevation: Option<f64>The z-coordinate at which to place this button when the button is disabled
(on_pressed is null).
This controls the size of the shadow below the floating action button.
Defaults to the same value as elevation. Setting this to zero
makes the floating action button work similar to an ElevatedButton but the titular
“floating” effect is lost. The value is always non-negative.
See also:
elevation, the default elevation.highlight_elevation, the elevation when the button is pressed.
mini: boolControls the size of this button.
By default, floating action buttons are non-mini and have a height and
width of 56.0 logical pixels. Mini floating action buttons have a height
and width of 40.0 logical pixels with a layout width and height of 48.0
logical pixels. (The extra 4 pixels of padding on each side are added as a
result of the floating action button having MaterialTapTargetSize::Padded
set on the underlying RawMaterialButton::material_tap_target_size.)
shape: Option<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 as well.
clip_behavior: ClipThe content will be clipped (or not) according to this option.
Defaults to Clip::None.
is_extended: boolTrue if this is an “extended” floating action button.
Typically “extended” buttons have a StadiumBorder shape
and have been created with the FloatingActionButton::extended
constructor.
The Scaffold animates the appearance of ordinary floating
action buttons with scale and rotation transitions. Extended
floating action buttons are scaled and faded in.
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: Option<MaterialTapTargetSize>Configures the minimum size of the tap target.
Defaults to ThemeData::material_tap_target_size.
See also:
MaterialTapTargetSize, for a description of how this affects tap targets.
enable_feedback: Option<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.
If null, FloatingActionButtonThemeData::enable_feedback is used.
If both are null, then default value is true.
See also:
Feedbackfor providing platform-specific feedback to certain actions.
extended_icon_label_spacing: Option<f64>The spacing between the icon and the label for an extended
FloatingActionButton.
If null, FloatingActionButtonThemeData::extended_icon_label_spacing is used.
If that is also null, the default is 8.0.
extended_padding: Option<EdgeInsetsGeometry>The padding for an extended FloatingActionButton’s content.
If null, FloatingActionButtonThemeData::extended_padding is used. If that
is also null, the default is
EdgeInsetsDirectional.only(start: 16.0, end: 20.0) if an icon is
provided, and EdgeInsetsDirectional.only(start: 20.0, end: 20.0) if not.
extended_text_style: Option<TextStyle>The text style for an extended FloatingActionButton’s label.
If null, FloatingActionButtonThemeData::extended_text_style is used. If
that is also null, then TextTheme::label_large with a letter spacing of 1.2
is used.
Implementations§
Source§impl FloatingActionButton
impl FloatingActionButton
Sourcepub fn new(on_pressed: Option<Listener>) -> FloatingActionButton
pub fn new(on_pressed: Option<Listener>) -> FloatingActionButton
Creates a circular floating action button.
The elevation, highlight_elevation,
and disabled_elevation parameters, if specified, must be
non-negative.
Sourcepub fn small(on_pressed: Option<Listener>) -> FloatingActionButton
pub fn small(on_pressed: Option<Listener>) -> FloatingActionButton
Creates a small circular floating action button.
This constructor overrides the default size constraints of the floating action button.
The elevation, focus_elevation,
hover_elevation,
highlight_elevation, and
disabled_elevation parameters, if specified, must be
non-negative.
Sourcepub fn large(on_pressed: Option<Listener>) -> FloatingActionButton
pub fn large(on_pressed: Option<Listener>) -> FloatingActionButton
Creates a large circular floating action button.
This constructor overrides the default size constraints of the floating action button.
The elevation, focus_elevation,
hover_elevation,
highlight_elevation, and
disabled_elevation parameters, if specified, must be
non-negative.
Sourcepub fn extended<K>(
on_pressed: Option<Listener>,
label: impl IntoWidget<K>,
) -> FloatingActionButton
pub fn extended<K>( on_pressed: Option<Listener>, label: impl IntoWidget<K>, ) -> FloatingActionButton
Creates a wider StadiumBorder-shaped floating action button with
an optional icon and a label.
The elevation, highlight_elevation,
and disabled_elevation parameters, if specified, must be
non-negative.
See also:
Sourcepub fn key(self, key: KeyRef) -> FloatingActionButton
pub fn key(self, key: KeyRef) -> FloatingActionButton
Dart FloatingActionButton(key:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> FloatingActionButton
pub fn child<K>(self, child: impl IntoWidget<K>) -> FloatingActionButton
Dart FloatingActionButton(child:).
Sourcepub fn tooltip(self, tooltip: impl Into<String>) -> FloatingActionButton
pub fn tooltip(self, tooltip: impl Into<String>) -> FloatingActionButton
Dart FloatingActionButton(tooltip:).
Sourcepub fn foreground_color(self, foreground_color: Color) -> FloatingActionButton
pub fn foreground_color(self, foreground_color: Color) -> FloatingActionButton
Dart FloatingActionButton(foregroundColor:).
Sourcepub fn background_color(self, background_color: Color) -> FloatingActionButton
pub fn background_color(self, background_color: Color) -> FloatingActionButton
Dart FloatingActionButton(backgroundColor:).
Sourcepub fn focus_color(self, focus_color: Color) -> FloatingActionButton
pub fn focus_color(self, focus_color: Color) -> FloatingActionButton
Dart FloatingActionButton(focusColor:).
Sourcepub fn hover_color(self, hover_color: Color) -> FloatingActionButton
pub fn hover_color(self, hover_color: Color) -> FloatingActionButton
Dart FloatingActionButton(hoverColor:).
Sourcepub fn splash_color(self, splash_color: Color) -> FloatingActionButton
pub fn splash_color(self, splash_color: Color) -> FloatingActionButton
Dart FloatingActionButton(splashColor:).
Sourcepub fn hero_tag(self, hero_tag: Option<Rc<dyn AnyEq>>) -> FloatingActionButton
pub fn hero_tag(self, hero_tag: Option<Rc<dyn AnyEq>>) -> FloatingActionButton
Dart FloatingActionButton(heroTag:); None is Dart’s explicit heroTag: null.
Sourcepub fn elevation(self, elevation: f64) -> FloatingActionButton
pub fn elevation(self, elevation: f64) -> FloatingActionButton
Dart FloatingActionButton(elevation:).
Sourcepub fn focus_elevation(self, focus_elevation: f64) -> FloatingActionButton
pub fn focus_elevation(self, focus_elevation: f64) -> FloatingActionButton
Dart FloatingActionButton(focusElevation:).
Sourcepub fn hover_elevation(self, hover_elevation: f64) -> FloatingActionButton
pub fn hover_elevation(self, hover_elevation: f64) -> FloatingActionButton
Dart FloatingActionButton(hoverElevation:).
Sourcepub fn highlight_elevation(
self,
highlight_elevation: f64,
) -> FloatingActionButton
pub fn highlight_elevation( self, highlight_elevation: f64, ) -> FloatingActionButton
Dart FloatingActionButton(highlightElevation:).
Sourcepub fn disabled_elevation(self, disabled_elevation: f64) -> FloatingActionButton
pub fn disabled_elevation(self, disabled_elevation: f64) -> FloatingActionButton
Dart FloatingActionButton(disabledElevation:).
Sourcepub fn mouse_cursor(
self,
mouse_cursor: impl Into<MouseCursorRef>,
) -> FloatingActionButton
pub fn mouse_cursor( self, mouse_cursor: impl Into<MouseCursorRef>, ) -> FloatingActionButton
Dart FloatingActionButton(mouseCursor:).
Sourcepub fn mini(self, mini: bool) -> FloatingActionButton
pub fn mini(self, mini: bool) -> FloatingActionButton
Dart FloatingActionButton(mini:), an argument of the unnamed constructor only, which
picks the small type when it is true.
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> FloatingActionButton
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> FloatingActionButton
Dart FloatingActionButton(shape:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> FloatingActionButton
pub fn clip_behavior(self, clip_behavior: Clip) -> FloatingActionButton
Dart FloatingActionButton(clipBehavior:).
Sourcepub fn is_extended(self, is_extended: bool) -> FloatingActionButton
pub fn is_extended(self, is_extended: bool) -> FloatingActionButton
Dart FloatingActionButton(isExtended:) and FloatingActionButton.extended(isExtended:).
Sourcepub fn focus_node(self, focus_node: FocusNodeRef) -> FloatingActionButton
pub fn focus_node(self, focus_node: FocusNodeRef) -> FloatingActionButton
Dart FloatingActionButton(focusNode:).
Sourcepub fn autofocus(self, autofocus: bool) -> FloatingActionButton
pub fn autofocus(self, autofocus: bool) -> FloatingActionButton
Dart FloatingActionButton(autofocus:).
Sourcepub fn material_tap_target_size(
self,
material_tap_target_size: MaterialTapTargetSize,
) -> FloatingActionButton
pub fn material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> FloatingActionButton
Dart FloatingActionButton(materialTapTargetSize:).
Sourcepub fn enable_feedback(self, enable_feedback: bool) -> FloatingActionButton
pub fn enable_feedback(self, enable_feedback: bool) -> FloatingActionButton
Dart FloatingActionButton(enableFeedback:).
Sourcepub fn extended_icon_label_spacing(
self,
extended_icon_label_spacing: f64,
) -> FloatingActionButton
pub fn extended_icon_label_spacing( self, extended_icon_label_spacing: f64, ) -> FloatingActionButton
Dart FloatingActionButton.extended(extendedIconLabelSpacing:).
Sourcepub fn extended_padding(
self,
extended_padding: impl Into<EdgeInsetsGeometry>,
) -> FloatingActionButton
pub fn extended_padding( self, extended_padding: impl Into<EdgeInsetsGeometry>, ) -> FloatingActionButton
Dart FloatingActionButton.extended(extendedPadding:).
Sourcepub fn extended_text_style(
self,
extended_text_style: TextStyle,
) -> FloatingActionButton
pub fn extended_text_style( self, extended_text_style: TextStyle, ) -> FloatingActionButton
Dart FloatingActionButton.extended(extendedTextStyle:).
Sourcepub fn icon<K>(self, icon: impl IntoWidget<K>) -> FloatingActionButton
pub fn icon<K>(self, icon: impl IntoWidget<K>) -> FloatingActionButton
Dart FloatingActionButton.extended(icon:), which the constructor stores as
child.
Trait Implementations§
Source§impl Debug for FloatingActionButton
impl Debug for FloatingActionButton
Source§impl StatelessWidget for FloatingActionButton
impl StatelessWidget for FloatingActionButton
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 build(&self, app: &mut App, context: BuildContext) -> WidgetRef
fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
Source§fn debug_check_constructor(&self)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
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 FloatingActionButton
impl !Send for FloatingActionButton
impl !Sync for FloatingActionButton
impl !UnwindSafe for FloatingActionButton
impl Forget for FloatingActionButton
impl Freeze for FloatingActionButtonwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const RcInner<dyn AnyEq> is !null: Freeze,
PhantomData<RcInner<dyn AnyEq>>: 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 MouseCursor> is !null: Freeze,
PhantomData<RcInner<dyn MouseCursor>>: 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,
&'static dyn ColorExtension: Freeze,
*const RcInner<dyn ColorExtension> is !null: Freeze,
PhantomData<RcInner<dyn ColorExtension>>: Freeze,
PhantomData<String>: Freeze,
*const RcInner<Paint> is !null: Freeze,
PhantomData<RcInner<Paint>>: Freeze,
PhantomData<Shadow>: Freeze,
PhantomData<FontFeature>: Freeze,
PhantomData<FontVariation>: Freeze,
impl Move for FloatingActionButton
impl Unpin for FloatingActionButtonwhere
Rc<dyn Key>: Unpin,
Rc<dyn Widget>: Unpin,
*const u8 is !null: Unpin,
Rc<dyn AnyEq>: Unpin,
Rc<dyn Fn(&mut App)>: Unpin,
NonZero<u32>: Unpin,
*const (): Unpin,
Rc<dyn MouseCursor>: Unpin,
Rc<dyn ShapeBorder>: Unpin,
&'static FocusNodeVTable: Unpin,
Rc<Keep>: Unpin,
&'static dyn ColorExtension: Unpin,
Rc<dyn ColorExtension>: Unpin,
Rc<Paint>: Unpin,
impl UnsafeUnpin for FloatingActionButtonwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const RcInner<dyn AnyEq> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn AnyEq>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const RcInner<dyn MouseCursor> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn MouseCursor>>: 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,
&'static dyn ColorExtension: UnsafeUnpin,
*const RcInner<dyn ColorExtension> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const RcInner<Paint> is !null: UnsafeUnpin,
PhantomData<RcInner<Paint>>: UnsafeUnpin,
PhantomData<Shadow>: UnsafeUnpin,
PhantomData<FontFeature>: UnsafeUnpin,
PhantomData<FontVariation>: 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<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.