UiButton class

Token-driven labeled action button.

Use this for commands with visible text such as "Save", "Cancel", and "Create invoice". For icon-only commands, prefer UiIconButton so the fixed hit target, icon sizing, and semantics stay consistent.

Button intent has one important package convention:

  • Omitted intent / UiIntent.defaultIntent renders as UiIntent.primary.
  • Use UiIntent.neutral for secondary or cancel actions.
  • Neutral, secondary, and destructive styles include their normal outline by default. Pass showBorder as false only when the button is placed inside an already framed or elevated surface and the extra outline would be visually noisy.
UiButton(
  label: 'Cancel',
  intent: UiIntent.neutral,
  showBorder: false, // embedded in an already bordered drawer/footer
  onPressed: onCancel,
)
Inheritance

Constructors

UiButton({Key? key, required String label, VoidCallback? onPressed, UiIntent intent = UiIntent.defaultIntent, UiSize size = UiSize.md, Widget? leading, Widget? trailing, bool loading = false, bool expand = false, FocusNode? focusNode, bool autofocus = false, String? semanticsLabel, List<BoxShadow>? boxShadow, bool showBorder = true})
const

Properties

autofocus bool
Whether this button should request focus when first built.
final
boxShadow List<BoxShadow>?
Optional custom shadow for floating action surfaces.
final
expand bool
Whether the button should fill the available horizontal space.
final
focusNode FocusNode?
Optional focus node for externally managed focus.
final
hashCode int
The hash code for this object.
no setterinherited
intent UiIntent
Visual role of the button. Defaults to the primary call-to-action.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String
Visible button text.
final
leading Widget?
Optional icon or small widget shown before label.
final
loading bool
Replaces the label content with a spinner and disables activation.
final
onPressed VoidCallback?
Called when the button is activated. null disables the button.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel String?
Spoken label. Defaults to label.
final
showBorder bool
Whether to paint the resolved variant outline.
final
size UiSize
Button height, padding, text, and icon scale.
final
trailing Widget?
Optional icon or small widget shown after label.
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