MButton class

A customizable button widget with different states and styling options.

The button supports outlined and filled styles, loading state, and customizable colors. It automatically handles tap events and provides a consistent appearance across the application.

Inheritance

Constructors

MButton.new({Key? key, required String label, Color? mainColor, Color? textColor, dynamic buttonFunc()?, bool? showOutline, bool? isLoading, bool? disabled, IconData? icon, double? fontSize, double height = 45})
Creates a styled button with text and optional action.
const

Properties

buttonFunc → dynamic Function()?
Callback function triggered when the button is tapped. If null, the button will appear disabled (but still visible).
final
disabled bool?
When true, the button will be non-interactive and displayed with reduced opacity. Defaults to false if not specified.
final
fontSize double?
final
hashCode int
The hash code for this object.
no setterinherited
height double
final
icon IconData?
If set, the icon will be placed to the left of the label.
final
isLoading bool?
When true, the button displays a loading indicator instead of text. Defaults to false if not specified.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String
The text displayed on the button. Will be displayed in uppercase if the button is actionable.
final
mainColor Color?
The primary color of the button. Affects background color (or outline color if showOutline is true) and text color based on contrast. If not provided, the mainColor from the MWidget config (or its default) will be used.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showOutline bool?
When true, the button will have an outlined style instead of filled. Defaults to false if not specified.
final
textColor Color?
The color that will be assigned to the text and the icon. If not provided, black will be used (unless mainColor is set to black and outlined is not true, in which case white will be used).
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
buildButton(Color color) Widget
buildDecoration(Color color) BoxDecoration
buildLoading(Color color) Widget
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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