M3EButtonDecoration class

Styling overrides for M3EButton.

Pass an instance to M3EButton.decoration to customize colors, shape, motion, and haptic feedback without subclassing.

Use M3EButtonDecoration.styleFrom for a seamless drop-in replacement experience when migrating from Flutter's standard ElevatedButton.styleFrom() API.

This class is @immutable.

Example

M3EButton(
  decoration: M3EButtonDecoration.styleFrom(
    backgroundColor: Colors.blue,
    disabledBackgroundColor: Colors.grey,
    motion: M3EMotion.custom(1600, 0.95),
  ),
  onPressed: () {},
  child: const Text('Custom Button'),
)

See also:

Implementers
Annotations

Constructors

M3EButtonDecoration({WidgetStateProperty<Color?>? backgroundColor, WidgetStateProperty<Color?>? foregroundColor, WidgetStateProperty<Color?>? shadowColor, WidgetStateProperty<double?>? elevation, WidgetStateProperty<BorderSide?>? side, WidgetStateProperty<MouseCursor?>? mouseCursor, WidgetStateProperty<Color?>? overlayColor, WidgetStateProperty<Color?>? surfaceTintColor, double? iconSize, IconAlignment? iconAlignment, TextStyle? textStyle, EdgeInsetsGeometry? padding, Size? minimumSize, Size? fixedSize, Size? maximumSize, VisualDensity? visualDensity, MaterialTapTargetSize? tapTargetSize, Duration? animationDuration, bool? enableFeedback, AlignmentGeometry? alignment, InteractiveInkFeatureFactory? splashFactory, ButtonLayerBuilder? backgroundBuilder, ButtonLayerBuilder? foregroundBuilder, M3EMotion? motion, M3EHapticFeedback? haptic, double? borderRadius, double? hoveredRadius, double? pressedRadius})
const

Properties

alignment AlignmentGeometry?
Custom alignment.
final
animationDuration Duration?
Custom animation duration.
final
backgroundBuilder ButtonLayerBuilder?
Custom background builder.
final
backgroundColor WidgetStateProperty<Color?>?
Background color of the button.
final
borderRadius double?
Default corner radius for the button.
final
elevation WidgetStateProperty<double?>?
Custom elevation.
final
enableFeedback bool?
Whether to enable feedback.
final
fixedSize Size?
Custom fixed size.
final
foregroundBuilder ButtonLayerBuilder?
Custom foreground builder.
final
foregroundColor WidgetStateProperty<Color?>?
Foreground (text/icon) color of the button.
final
haptic M3EHapticFeedback?
Haptic feedback level.
final
hashCode int
The hash code for this object.
no setteroverride
hoveredRadius double?
Custom corner radius when hovered.
final
iconAlignment IconAlignment?
The alignment of the icon within the button.
final
iconSize double?
Custom icon size.
final
maximumSize Size?
Custom maximum size.
final
minimumSize Size?
Custom minimum size.
final
motion M3EMotion?
Spring physics configuration.
final
mouseCursor WidgetStateProperty<MouseCursor?>?
Custom mouse cursor.
final
overlayColor WidgetStateProperty<Color?>?
The color of the overlay that appears behind the button.
final
padding EdgeInsetsGeometry?
Custom padding.
final
pressedRadius double?
Custom corner radius when pressed.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shadowColor WidgetStateProperty<Color?>?
Custom shadow color.
final
side WidgetStateProperty<BorderSide?>?
Custom border side.
final
splashFactory InteractiveInkFeatureFactory?
Custom splash factory.
final
surfaceTintColor WidgetStateProperty<Color?>?
The color of the surface tint overlay.
final
tapTargetSize MaterialTapTargetSize?
Custom tap target size.
final
textStyle TextStyle?
Custom text style.
final
visualDensity VisualDensity?
Custom visual density.
final

Methods

copyWith({WidgetStateProperty<Color?>? backgroundColor, WidgetStateProperty<Color?>? foregroundColor, WidgetStateProperty<Color?>? shadowColor, WidgetStateProperty<double?>? elevation, WidgetStateProperty<BorderSide?>? side, WidgetStateProperty<MouseCursor?>? mouseCursor, WidgetStateProperty<Color?>? overlayColor, WidgetStateProperty<Color?>? surfaceTintColor, double? iconSize, IconAlignment? iconAlignment, TextStyle? textStyle, EdgeInsetsGeometry? padding, Size? minimumSize, Size? fixedSize, Size? maximumSize, VisualDensity? visualDensity, MaterialTapTargetSize? tapTargetSize, Duration? animationDuration, bool? enableFeedback, AlignmentGeometry? alignment, InteractiveInkFeatureFactory? splashFactory, ButtonLayerBuilder? backgroundBuilder, ButtonLayerBuilder? foregroundBuilder, M3EMotion? motion, M3EHapticFeedback? haptic, double? borderRadius, double? hoveredRadius, double? pressedRadius}) M3EButtonDecoration
Creates a copy of this decoration with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

styleFrom({Color? foregroundColor, Color? backgroundColor, Color? disabledForegroundColor, Color? disabledBackgroundColor, Color? shadowColor, Color? surfaceTintColor, Color? overlayColor, double? iconSize, IconAlignment? iconAlignment, double? elevation, TextStyle? textStyle, EdgeInsetsGeometry? padding, Size? minimumSize, Size? fixedSize, Size? maximumSize, BorderSide? side, MouseCursor? enabledMouseCursor, MouseCursor? disabledMouseCursor, VisualDensity? visualDensity, MaterialTapTargetSize? tapTargetSize, Duration? animationDuration, bool? enableFeedback, AlignmentGeometry? alignment, InteractiveInkFeatureFactory? splashFactory, ButtonLayerBuilder? backgroundBuilder, ButtonLayerBuilder? foregroundBuilder, M3EMotion? motion, M3EHapticFeedback? haptic, double? borderRadius, double? hoveredRadius, double? pressedRadius}) M3EButtonDecoration
Factory constructor to seamlessly migrate from Flutter's official ButtonStyle / styleFrom(). Flat colors are automatically converted into robust WidgetStateProperty wrappers.