CustomButton class

CustomButton class custom button widget This class is used to create a custom button If you set your application primary color then it will use that color using CustomColor.kPrimaryColor. Here primary is used to set the button color. This button has a isDisable property to disable the button. We can set the disableColor to change the disable button color. Only one required property is label other properties are optional. If you don't set the optional properties then it will use the default value. This button has a loading property to show the loading indicator in the button. We can set the loadingColor to change the loading indicator color. We can set the prefixImage and suffixImage to show the image before and after the label. We can set the prefixImageHeight, prefixImageWidth, prefixImageColor, suffixImageHeight, suffixImageWidth, suffixImageColor to change the image properties. elevation is used to set the elevation of the button. boxShadowColor is used to set the shadow color of the button. borderColor is used to set the border color of the button. labelColor is used to set the label color of the button. fontSize is used to set the font size of the label. fontWeight is used to set the font weight of the label. iconData is used to set the icon before the label. height is used to set the height of the button. borderWidth is used to set the border width of the button. isBorder is used to set the border of the button. width is used to set the width of the button. borderRadiusAll is used to set the border radius of the button. borderRadius is used to set custom border radius of the button.

Example:

CustomButton(
 label: 'Login',
 onPressed: () {
 print('Login');
 },
 primary: Colors.red,
 borderColor: Colors.red,
 labelColor: Colors.white,
 fontSize: 16,
 fontWeight: FontWeight.bold,
 prefixImage: 'assets/images/login.png',
);
Inheritance

Constructors

CustomButton({Key? key, required String label, dynamic onPressed()?, Color? primary, Color? borderColor, Color? labelColor, double? fontSize, FontWeight? fontWeight, TextStyle? labelStyle, String? iconData, double? height, double? borderWidth, double? elevation, Color? boxShadowColor, bool isBorder = false, double? width, double? borderRadiusAll, double? marginHorizontal, double? marginVertical, EdgeInsetsGeometry? margin, double? contentPadding, double? contentHorizontalPadding, double? contentVerticalPadding, EdgeInsetsGeometry? padding, bool isDisable = false, String? prefixImage, String? suffixImage, double? suffixImageHeight, double? suffixImageWidth, Color? suffixImageColor, double? prefixImageHeight, double? prefixImageWidth, Color? prefixImageColor, bool loading = false, Color? loadingColor, Color? disableColor, double? loadingHeight, double? loadingWidth, double loadingStrokeWidth = 4.0, BorderRadiusGeometry? borderRadius})
const

Properties

borderColor Color?
borderColor is used to set the border color of the button This is an optional property This is a color type property
final
borderRadius BorderRadiusGeometry?
borderRadius is used to set the custom border radius of the button This is an optional property This is a BorderRadiusGeometry type property
final
borderRadiusAll double?
borderRadiusAll is used to set the border radius of the button This is an optional property This is a double type property
final
borderWidth double?
borderWidth is used to set the border width of the button This is an optional property This is a double type property
final
boxShadowColor Color?
boxShadowColor is used to set the shadow color of the button This is an optional property This is a color type property
final
contentHorizontalPadding double?
contentHorizontalPadding is used to set the content horizontal padding of the button This is an optional property This is a double type property
final
contentPadding double?
contentPadding is used to set the content padding of the button This is an optional property This is a double type property
final
contentVerticalPadding double?
contentVerticalPadding is used to set the content vertical padding of the button This is an optional property This is a double type property
final
disableColor Color?
disableColor is used to set the disable button color This is an optional property This is a color type property
final
elevation double?
elevation is used to set the elevation of the button This is an optional property This is a double type property
final
fontSize double?
fontSize is used to set the font size of the label This is an optional property This is a double type property
final
fontWeight FontWeight?
fontWeight is used to set the font weight of the label This is an optional property This is a font weight type property
final
hashCode int
The hash code for this object.
no setterinherited
height double?
height is used to set the height of the button This is an optional property This is a double type property
final
iconData String?
iconData is used to set the icon before the label This is an optional property This is a string type property
final
isBorder bool
isBorder is used to set the border of the button This is an optional property This is a bool type property
final
isDisable bool
isDisable is used to disable the button This is an optional property This is a bool type property
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String
label is used to set the button label This is a required property This is a string type property This is a mandatory property
final
labelColor Color?
labelColor is used to set the label color of the button This is an optional property This is a color type property
final
labelStyle TextStyle?
labelStyle is used to set the label style of the button This is an optional property This is a text style type property
final
loading bool
loading is used to show the loading indicator in the button This is an optional property This is a bool type property
final
loadingColor Color?
loadingColor is used to set the loading indicator color This is an optional property This is a color type property
final
loadingHeight double?
loadingHeight is used to set the height of the loading indicator This is an optional property This is a double type property
final
loadingStrokeWidth double
loadingStrokeWidth is used to set the stroke width of the loading indicator This is an optional property This is a double type property
final
loadingWidth double?
loadingWidth is used to set the width of the loading indicator This is an optional property This is a double type property
final
margin EdgeInsetsGeometry?
margin is used to set the margin of the button This is an optional property This is a EdgeInsetsGeometry type property
final
marginHorizontal double?
marginHorizontal is used to set the horizontal margin of the button This is an optional property This is a double type property
final
marginVertical double?
marginVertical is used to set the vertical margin of the button This is an optional property This is a double type property
final
onPressed → dynamic Function()?
onPressed is used to set the button action This is an optional property This is a function type property
final
padding EdgeInsetsGeometry?
padding is used to set the padding of the button This is an optional property This is a EdgeInsetsGeometry type property
final
prefixImage String?
prefixImage is used to set the image before the label This is an optional property This is a string type property
final
prefixImageColor Color?
prefixImageColor is used to set the color of the prefix image This is an optional property This is a color type property
final
prefixImageHeight double?
prefixImageHeight is used to set the height of the prefix image This is an optional property This is a double type property
final
prefixImageWidth double?
prefixImageWidth is used to set the width of the prefix image This is an optional property This is a double type property
final
primary Color?
primary is used to set the button color This is an optional property This is a color type property
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
suffixImage String?
suffixImage is used to set the image after the label This is an optional property This is a string type property
final
suffixImageColor Color?
suffixImageColor is used to set the color of the suffix image This is an optional property This is a color type property
final
suffixImageHeight double?
suffixImageHeight is used to set the height of the suffix image This is an optional property This is a double type property
final
suffixImageWidth double?
suffixImageWidth is used to set the width of the suffix image This is an optional property This is a double type property
final
width double?
width is used to set the width of the button This is an optional property This is a double type property
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