FlintButton class

A customizable and responsive button widget for Flint UI, designed to render as HTML, text, or JSON — and now supports client-side actions via FlintScript or FlintAction.

Each FlintButton automatically generates a unique id that can be used for DOM updates or targeting via scripts. Developers can override the id manually if desired.

Example usage:

FlintButton(
  text: 'Save',
  onClick: FlintAction.api('/api/user/update', {'id': 1, 'name': 'Hybiekay'}),
)

Or a static inline script:

FlintButton(
  text: 'Alert',
  onClick: FlintScript.custom("alert('Hello Flint!');"),
)
Inheritance

Constructors

FlintButton({String? id, required String text, String? url, ButtonStyle? style, EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0), BorderRadius borderRadius = const BorderRadius.circular(6.0), BoxShadow shadow = const BoxShadow(offsetY: 2, blurRadius: 4, color: 'rgba(0, 0, 0, 0.1)'), ButtonState state = ButtonState.enabled, String? semanticLabel, bool fullWidth = false, ButtonSize size = ButtonSize.medium, String? icon, dynamic onClick})
Creates a new FlintButton.

Properties

borderRadius BorderRadius
Border radius for rounded corners.
final
fullWidth bool
Whether the button should expand to full width.
final
hashCode int
The hash code for this object.
no setterinherited
icon String?
Optional icon (emoji or symbol).
final
id String
Unique identifier for this widget instance. Automatically generated unless overridden by user.
final
onClick → dynamic
Optional script to run when clicked.
final
padding EdgeInsets
Padding around content.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
script FlintScript?
finalinherited
semanticLabel String?
Accessibility label.
final
shadow BoxShadow
Drop shadow for elevation effect.
final
size ButtonSize
Visual size variant (small, medium, large).
final
state ButtonState
Whether the button is clickable or disabled.
final
style ButtonStyle?
Optional visual appearance configuration.
final
text String
The text displayed inside the button.
final
url String?
The URL or target destination the button links to (if applicable).
final

Methods

buildTemplate() FlintWidget
Build the widget template - MUST be implemented by subclasses
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renderScriptAttributes() String
Render attached script to HTML attributes
inherited
toHtml() String
Render to HTML (for emails, web)
override
toJson() Map<String, dynamic>
Render to intermediate JSON (for APIs, mobile apps, etc.)
override
toString() String
A string representation of this object.
inherited
toText() String
Render to plain text (fallback, CLI, etc.)
override

Operators

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