Button class
{{template flint_button} 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 Button 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:
Button(
text: 'Save',
onClick: FlintAction.api('/api/user/update', {'id': 1, 'name': 'Hybiekay'}),
)
Or a static inline script:
Button(
text: 'Alert',
onClick: FlintScript.custom("alert('Hello Flint!');"),
)
{{endtemplate}
- Inheritance
-
- Object
- FlintWidget
- Button
Constructors
-
Button({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, String? xData, String? xInit, String? xShow, Map<
String, String> ? xBind, Map<String, String> ? xOn, String? xText, String? xHtml, String? xModel, String? xModelable, String? xFor, String? xTransition, String? xEffect, bool? xIgnore, String? xRef, bool? xCloak, String? xTeleport, bool? xIf, String? xId}) - Creates a new Button.
Properties
- borderRadius → BorderRadius
-
Border radius for rounded corners.
final
-
directives
→ Map<
String, String> -
no setterinherited
- 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
-
xBind
→ Map<
String, String> -
finalinherited
- xCloak → bool?
-
finalinherited
- xData → String?
-
finalinherited
- xEffect → String?
-
finalinherited
- xFor → String?
-
finalinherited
- xHtml → String?
-
finalinherited
- xId → String?
-
finalinherited
- xIf → bool?
-
finalinherited
- xIgnore → bool?
-
finalinherited
- xInit → String?
-
finalinherited
- xModel → String?
-
finalinherited
- xModelable → String?
-
finalinherited
-
xOn
→ Map<
String, String> -
finalinherited
- xRef → String?
-
finalinherited
- xShow → String?
-
finalinherited
- xTeleport → String?
-
finalinherited
- xText → String?
-
finalinherited
- xTransition → String?
-
finalinherited
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
-
renderAttributes(
{String? style}) → String -
---------------- Helper ----------------
Converts ID + directives + optional style to HTML attributes
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