Button class

A styled button component.

Can render as either a <button> or <a> element depending on whether href is provided. Use href for CTA buttons that navigate to other pages.

Inheritance

Constructors

Button({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonVariant variant = ButtonVariant.primary, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.accent({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
Accent variant with gradient background. Useful for prominent CTA buttons.
const
Button.destructive({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.ghost({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.info({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
const
Button.outline({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.primary({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.secondary({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.success({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const
Button.warning({String? label, Widget? child, Widget? icon, Widget? trailing, void onPressed()?, ButtonSize size = ButtonSize.medium, bool disabled = false, bool loading = false, bool fullWidth = false, Map<String, String>? attributes, String? id, String? href, bool showArrow = false, Key? key})
const

Properties

attributes Map<String, String>?
final
child Widget?
final
disabled bool
final
fullWidth bool
final
hashCode int
The hash code for this object.
no setterinherited
href String?
If provided, renders the button as an anchor tag (<a>) instead of <button>. Useful for CTA buttons that navigate to other pages.
final
icon Widget?
final
id String?
final
key Key?
Controls how one component replaces another component in the tree.
finalinherited
label String?
final
loading bool
final
onPressed → void Function()?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showArrow bool
Whether to show an arrow indicator after the label. Useful for CTA buttons to indicate navigation.
final
size ButtonSize
final
trailing Widget?
final
variant ButtonVariant
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this component.
override
createElement() Element
Creates a StatelessElement to manage this component's location in the tree.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRebuild(covariant Component newComponent) bool
Implement this method to determine whether a rebuild can be skipped.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited