PrimaryButton Documentation
Overview
The PrimaryButton
widget is a versatile button component designed for primary actions in a Flutter application. It extends CwButton
, providing customizable styling options such as background color, shadow, gradient, and border properties.
Parameters Explanation
Below are the parameters available for PrimaryButton
:
onButtonTap
(required): The callback function executed when the button is tapped.prefixIcon
: An optional widget displayed before the label (e.g., an icon or image).suffixIcon
: An optional widget displayed after the label.label
: AText
widget that contains the button text.backgrounColor
: Sets the background color of the button.elevation
: Defines the button’s elevation, adding a shadow effect.shadowColor
: Specifies the color of the button’s shadow.padding
: Controls the internal padding of the button.borderRadius
: Defines the border radius to control the button's shape.splashColor
: Specifies the color when the button is tapped.buttonBorder
: Allows custom border styles for the button.buttonShadow
: Defines a list ofBoxShadow
effects for the button.gradient
: Adds a gradient background to the button.splashFactor
: Defines the ink splash effect on tap.hoverColor
: Defines the color when the button is hovered over.buttonWidth
: Sets the width of the button.buttonHeight
: Sets the height of the button.
Usage Example
PrimaryButton(
onButtonTap: () => print("Primary Button Clicked"),
label: Text("Primary Button"),
backgrounColor: Colors.blue,
borderRadius: BorderRadius.circular(10),
elevation: 4,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
);
Source Code Repository
Find the full source code on GitHub: GitHub Repository