main_button 0.0.6 main_button: ^0.0.6 copied to clipboard
is a versatile Flutter package for creating highly customizable buttons with options for loading indicators, disabled states, and flexible content.
CustomIconButton #
Overview #
CustomIconButton
is a versatile Flutter widget designed to provide a customizable button with various styling and functional options. It supports different states, including loading and disabled, and allows you to configure its appearance with properties like padding, border radius, and colors. You can use it to display an image, an icon, or text.
Features #
- Customizable Width: Set a specific width for the button or use a default width.
- Padding & Border Radius: Adjust internal padding and corner roundness.
- Interactive States: Handle press events and manage loading or disabled states.
- Flexible Content: Display text, an icon, or an image inside the button.
- Styling Options: Customize background color, text color, border color, opacity, and shadow.
Properties #
width
: The width of the button. Ifnull
, a default width is used.padding
: Internal padding of the button. Default is12
.borderRadius
: Radius of the button's corners. Default is8
.onPressed
: Callback triggered when the button is pressed. Ifnull
, the button will not respond to taps.label
: Text to display on the button. Ifnull
, no text will be shown.child
: A widget to display inside the button for custom content.imagePath
: Path to an image asset to display inside the button. Ifnull
, no image will be shown.icon
: A widget to use as an icon inside the button. Ifnull
, no icon will be shown.backgroundColor
: Background color of the button. Defaults to theme's primary color ifnull
.textColor
: Color of the text displayed on the button. Defaults to theme's scaffold background color ifnull
.disableColor
: Color of the button when it is disabled. Defaults to a theme-based color ifnull
.isLoading
: Iftrue
, the button will display a loading indicator.opacity
: Controls the button's transparency. Defaults to0.5
ifnull
.showShadow
: Iftrue
, a shadow will be applied to the button.borderColor
: Color of the button's border.smallSize
: Iftrue
, renders the button smaller.isDisable
: Iftrue
, renders the button in a disabled state.
Usage #
To use CustomIconButton
in your Flutter app, you can create an instance of the button and configure its properties according to your needs. Below is an example of how to use the widget:
CustomIconButton(
width: 100,
padding: 16,
borderRadius: 12,
onPressed: () {
// Handle button press
},
label: 'Click Me',
icon: Icon(Icons.add),
imagePath: 'assets/my_image.png',
backgroundColor: Colors.blue,
textColor: Colors.white,
disableColor: Colors.grey,
isLoading: false,
showShadow: true,
opacity: 0.8,
borderColor: Colors.black,
smallSize: false,
isDisable: false,
)