Button
Displays a button or a widget that looks like a button.
Installation
Usage
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| text | String? | null | Label text displayed on the button. |
| icon | IconData? | null | Leading icon displayed before the text. |
| onPressed | VoidCallback? | null | Callback triggered on tap. Pass null to disable. |
| variant | ButtonVariant | primary | Style variant of the button. |
| size | ButtonSize | md | Size preset controlling height, padding, and font size. |
| isLoading | bool | false | When true, replaces content with a circular spinner. |
| isDisabled | bool | false | When true, disables interaction and dims the button. |
| iconOnly | bool | false | When true, renders only the icon without text. |
| child | Widget? | null | Custom child widget. Overrides text and icon. |
| backgroundColor | Color? | — | Override the background color. |
| foregroundColor | Color? | — | Override the text and icon color. |
| hoverBackgroundColor | Color? | — | Background color on hover. |
| pressedBackgroundColor | Color? | — | Background color on press. |
| disabledBackgroundColor | Color? | — | Background color when disabled. |
| disabledForegroundColor | Color? | — | Text color when disabled. |
| loadingIndicatorColor | Color? | — | Color of the loading spinner. |
| borderColor | Color? | — | Border color (effective with outline or custom variant). |
| borderWidth | double? | — | Border stroke width. |
| elevation | double? | 0 | Shadow elevation. |
| hoverElevation | double? | — | Elevation on hover. |
| pressedElevation | double? | — | Elevation on press. |
| disabledElevation | double? | — | Elevation when disabled. |
| borderRadius | double? | 8.0 | Corner radius in logical pixels. |
| width | double? | — | Fixed width. |
| height | double? | — | Fixed height. |
| minWidth | double? | — | Minimum width. |
| minHeight | double? | — | Minimum height. |
| fontSize | double? | — | Font size of the label text. |
| iconSize | double? | — | Size of the icon. |
| fontWeight | FontWeight? | w600 | Font weight of the label text. |
| padding | EdgeInsetsGeometry? | — | Inner padding override. |
| animationDuration | Duration? | 200ms | Duration of the press animation. |
| animationCurve | Curve? | easeInOut | Curve of the press animation. |
| shape | BoxShape? | — | Set to BoxShape.circle for a circular button. |
| gradient | Gradient? | — | Gradient fill (only applied in custom variant). |
| boxShadow | List<BoxShadow>? | — | Custom box shadow (only applied in custom variant). |
| loadingSize | double? | — | Size of the loading spinner. |
| overlayColor | Color? | — | Ripple/overlay color on interaction. |
| contentAlignment | MainAxisAlignment? | center | Alignment of the row containing icon and text. |
| textStyle | TextStyle? | — | Full text style override. |
Variants
FlutButton provides several variants. Choose the one that best communicates the intent of the action.
Primary
The default variant. Use for the most important action on a screen.
Secondary
Use for secondary or supporting actions alongside a primary button.
Outline
A bordered button with a transparent background. Use for less prominent actions.
Ghost
No background or border. Useful for toolbar actions and inline controls.
Link
Styled like a hyperlink with an underline. Use for navigational actions.
Destructive
Red-toned button for irreversible actions like deleting or removing.
Custom
Full control over colors, shape, gradient, and shadows.
Sizes
Sm
Height of 32, font size 14. For compact UIs or inline actions.
Md
Height of 40, font size 16. The default size.
Lg
Height of 48, font size 18. For prominent call-to-action buttons.
Icon
Square button at 40×40, designed for icon-only buttons.
Custom
Fully control the height, width, font size, and padding.
With Icons
Add a leading icon alongside text using the icon parameter.
For icon-only buttons, use Button.icon():
Loading State
Set isLoading: true to replace the button content with a spinner. The button remains non-interactive while loading.
Disabled State
Set isDisabled: true to prevent interaction. The button appears dimmed.
Gradient Button
Use Button.gradient() to apply a linear or radial gradient fill.
Circular Button
Use Button.circular() for a perfectly round icon button.
Helper Class
The Button helper class provides named constructors for each variant and style combination.