CustomActionButton class

A customizable button widget that can be configured as elevated, flat, minimal, or long-press button types. Provides a flexible API to adjust styles, colors, shapes, and behaviors.

The CustomActionButton supports different visual styles through the ButtonType enum and offers factory constructors for convenience.

Example usage:

CustomActionButton.elevated(
  onPressed: () {},
  child: Text('Elevated Button'),
);

CustomActionButton.icon(
  onPressed: () {},
  icon: Icon(Icons.add),
  label: Text('Add Item'),
);
Inheritance

Constructors

CustomActionButton({Key? key, required Widget child, Widget? icon, double iconSpacing = 8.0, ButtonType? buttonType, VoidCallback? onPressed, VoidCallback? onLongPress, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, double? elevation, double? borderRadius, double? width, double? height, double minHeight = 60.0, OutlinedBorder? shape, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates a CustomActionButton with the given parameters.
const
CustomActionButton.elevated({Key? key, required VoidCallback? onPressed, required Widget child, Widget? icon, double iconSpacing = 8.0, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledForegroundColor, Color? disabledBorderColor, Color? borderColor, double elevation = 2.0, double borderRadius = 8.0, BorderSide? side, OutlinedBorder? shape, double? width, double? height, double minHeight = 60.0, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates an elevated button.
factory
CustomActionButton.flat({Key? key, required VoidCallback? onPressed, required Widget child, Widget? icon, double iconSpacing = 8.0, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, double borderRadius = 8.0, BorderSide? side, OutlinedBorder? shape, double? width, double? height, double minHeight = 60.0, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates a flat button.
factory
CustomActionButton.icon({Key? key, required VoidCallback? onPressed, required Widget icon, required Widget label, ButtonType baseType = ButtonType.elevated, double iconSpacing = 8.0, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, double? elevation, double? borderRadius, double? width, double? height, double minHeight = 60.0, OutlinedBorder? shape, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates a button with an icon and a label.
factory
CustomActionButton.iconOnly({Key? key, required VoidCallback? onPressed, required Widget icon, ButtonType baseType = ButtonType.elevated, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, double? size = 48.0, double? iconSize, EdgeInsetsGeometry? margin, OutlinedBorder? shape, double? elevation, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize tapTargetSize = MaterialTapTargetSize.padded})
Creates a circular button that displays only an icon.
factory
CustomActionButton.longPress({Key? key, required VoidCallback? onPressed, required VoidCallback? onLongPress, required Widget child, Widget? icon, double iconSpacing = 8.0, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, double elevation = 2.0, double borderRadius = 8.0, BorderSide? side, OutlinedBorder? shape, double? width, double? height, double minHeight = 60.0, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates a long-press button.
factory
CustomActionButton.minimal({Key? key, required VoidCallback? onPressed, required Widget child, Widget? icon, double iconSpacing = 8.0, Color? borderColor, Color? foregroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? shadowColor, double? width, double? height, double minHeight = 60.0, OutlinedBorder? shape, EdgeInsetsGeometry? padding, Gradient? disabledBackgroundGradient, EdgeInsetsGeometry? margin, MaterialTapTargetSize? tapTargetSize})
Creates a minimal button.
factory
CustomActionButton.rounded({Key? key, required VoidCallback? onPressed, required Widget child, Widget? icon, double iconSpacing = 8.0, Color? backgroundColor, Color? foregroundColor, Color? shadowColor, Color? splashColor, Color? disabledBackgroundColor, Color? disabledBorderColor, Color? disabledForegroundColor, Color? borderColor, double? width, double? height, double minHeight = 60.0, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, double elevation = 2.0, Gradient? backgroundGradient, Gradient? disabledBackgroundGradient, InteractiveInkFeatureFactory? splashFactory, MaterialTapTargetSize? tapTargetSize})
Creates a fully rounded button.
factory

Properties

backgroundColor Color?
The background color of the button.
final
backgroundGradient Gradient?
Background gradients for the button.
final
borderColor Color?
The border color of the button.
final
borderRadius double?
The border radius of the button.
final
buttonType ButtonType?
The type of button to display.
final
child Widget
The child widget to display inside the button. If icon is also provided, this will be treated as the label.
final
disabledBackgroundColor Color?
The background color of the button when it is disabled.
final
disabledBackgroundGradient Gradient?
final
disabledBorderColor Color?
The border color of the button when it is disabled.
final
disabledForegroundColor Color?
The text color of the button when it is disabled.
final
elevation double?
The elevation of the button.
final
foregroundColor Color?
The foreground color (text/icon color) of the button.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
The height of the button.
final
icon Widget?
An optional icon to display before the child.
final
iconSpacing double
The spacing between the icon and the child. Defaults to 8.0.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
margin EdgeInsetsGeometry?
The external margin around the button.
final
minHeight double
The minimum height of the button. Defaults to 60.0. If set to 0, the button will adapt to the minimum possible height required by its content.
final
onLongPress VoidCallback?
The callback that is called when the button is long-pressed. Only used when buttonType is ButtonType.longPress.
final
onPressed VoidCallback?
The callback that is called when the button is tapped.
final
padding EdgeInsetsGeometry?
The amount of space to surround the child inside the button.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shadowColor Color?
The shadow color of the button.
final
shape OutlinedBorder?
The shape of the button's material.
final
splashColor Color?
The splash color of the button when tapped.
final
splashFactory InteractiveInkFeatureFactory?
The splash factory to define interaction effects.
final
tapTargetSize MaterialTapTargetSize?
Configures the minimum size of the tap target.
final
width double?
The width of the button.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CustomActionButton>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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