MainButton class
A custom icon button widget that provides a variety of styling and functionality options.
This button supports various states such as loading and disabled, allows customization of its appearance through properties like padding, border radius, and colors, and can display either an image, an icon, or text.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MainButton
Constructors
- MainButton({Key? key, double? width = double.infinity, double? maxWidth = 370, double? height = 44, EdgeInsets? padding, double borderRadius = 8, required String label, void onPressed()?, Color? backgroundColor, Color? textColor, Color? disableColor, bool isLoading = false, bool showShadow = true, bool isDisable = false, Color borderColor = Colors.transparent, bool smallSize = false, double? opacity, MainButtonEnum type = MainButtonEnum.primary, TextStyle? labelStyle, double? fontSize})
-
Creates a new instance of
CustomIconButton
.const - MainButton.icon({required String label, required IconType iconType, double? width = double.infinity, TextStyle? labelStyle, double? fontSize, double? maxWidth = 370, double borderRadius = 8, double height = 44, bool smallSize = false, double spaceBetweenIconAndText = 8.0, String? imagePath, IconData? icon, void onPressed()?, double? imageSize, double? opacity, Color? textColor, Color? backgroundColor, EdgeInsets? padding, Color? disableColor, bool isLoading = false, bool showShadow = false, bool isDisable = false, Color borderColor = Colors.transparent, MainButtonEnum type = MainButtonEnum.primary})
-
factory
Properties
- backgroundColor → Color?
-
The background color of the button. If
null
, a default color will be used.final - borderColor → Color
-
The color of the button's border. This is used to outline the button.
final
- borderRadius → double
-
The border radius of the button. This defines how rounded the button's corners are.
Default is
8
.final - disableColor → Color?
-
The color of the button when it is disabled. If
null
, a default disabled color will be used.final - fontSize → double?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
The height of the button. If
null
, the button will use a default width based on other properties. Default is44
.final - isDisable → bool
-
Indicates whether the button is disabled. If
true
, the button will be rendered in a disabled state and will not respond to user interaction.final - isLoading → bool
-
Indicates whether the button is in a loading state. If
true
, the button will show a loading indicator.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → String
-
The label text displayed on the button. If
null
, no text will be shown.final - labelStyle → TextStyle?
-
final
- maxWidth → double?
-
final
- onPressed → void Function()?
-
A callback function that is triggered when the button is pressed. If
null
, the button will not respond to taps.final - opacity → double?
-
The opacity of the button. This controls how transparent the button is. If
null
, a default opacity will be used.final - padding → EdgeInsets?
-
The padding inside the button. This determines the space between the button's content and its border.
Default is
12
.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showShadow → bool
-
Indicates whether a shadow should be shown behind the button. If
true
, a shadow will be applied.final - smallSize → bool
-
Indicates whether the button is small-sized. If
true
, the button will be rendered smaller.final - textColor → Color?
-
The color of the text displayed on the button. If
null
, a default text color will be used.final - type → MainButtonEnum
-
final
- width → double?
-
The width of the button. If
null
, the button will use a default width based on other properties.final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
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