DraftModeUIButton class

A platform-adaptive button that renders as CupertinoButton on iOS and a framework-owned Material button family on Android.

Use the named factory constructors DraftModeUIButton.text, DraftModeUIButton.icon, and DraftModeUIButton.label to create buttons with theme-resolved content. For common actions see DraftModeUIButtonPresets.

{@tool snippet}

DraftModeUIButton.text(
  'Submit',
  autoPending: true,
  onPressed: () => repository.save(),
)

{@end-tool}

Inheritance

Constructors

DraftModeUIButton({Key? key, required Widget child, Widget? pendingChild, bool isPending = false, VoidCallback? onPressed, DraftModeUIButtonSize size = DraftModeUIButtonSize.large, DraftModeUIButtonVariant variant = DraftModeUIButtonVariant.primary, Color? backgroundColor, Color? textColor, bool stretched = true, EdgeInsetsGeometry? padding, bool autoPending = false})
const
DraftModeUIButton.icon(IconData icon, {Key? key, Widget? pendingChild, bool isPending = false, VoidCallback? onPressed, DraftModeUIButtonSize size = DraftModeUIButtonSize.medium, DraftModeUIButtonVariant variant = DraftModeUIButtonVariant.plain, Color? backgroundColor, Color? textColor, bool stretched = false, EdgeInsetsGeometry? padding, bool autoPending = false})
Creates an icon-only button. Defaults to DraftModeUIButtonVariant.plain and stretched false.
factory
DraftModeUIButton.label(String text, {required IconData icon, Key? key, Widget? pendingChild, bool isPending = false, VoidCallback? onPressed, DraftModeUIButtonSize size = DraftModeUIButtonSize.large, DraftModeUIButtonVariant variant = DraftModeUIButtonVariant.primary, Color? backgroundColor, Color? textColor, bool stretched = true, EdgeInsetsGeometry? padding, bool autoPending = false, TextStyle? textStyle, double? gap})
Creates a button with an icon and text label arranged in a Row.
factory
DraftModeUIButton.text(String text, {Key? key, Widget? pendingChild, bool isPending = false, VoidCallback? onPressed, DraftModeUIButtonSize size = DraftModeUIButtonSize.large, DraftModeUIButtonVariant variant = DraftModeUIButtonVariant.primary, Color? backgroundColor, Color? textColor, bool stretched = true, EdgeInsetsGeometry? padding, bool autoPending = false, TextStyle? textStyle, TextAlign? textAlign, int? maxLines, TextOverflow? overflow})
Creates a button that renders the provided text with DraftMode sizing tokens. Callers can override the generated Text styling via textStyle, textAlign, maxLines, or overflow.
factory

Properties

autoPending → bool
When true, the button automatically manages its own pending state.
final
backgroundColor → Color?
Overrides the variant-resolved background color.
final
child → Widget
The widget displayed inside the button when not in a pending state.
final
contentKind → DraftModeAdaptiveButtonContentKind
no setter
hashCode → int
The hash code for this object.
no setterinherited
isPending → bool
Whether the button is currently in a pending (loading) state.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onPressed → VoidCallback?
Called when the button is tapped.
final
padding → EdgeInsetsGeometry?
Overrides the default padding resolved from size and stretched.
final
pendingChild → Widget?
Optional widget shown in place of child while the button is pending.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → DraftModeUIButtonSize
The semantic size of the button.
final
stretched → bool
Whether the button stretches to fill the available width.
final
textColor → Color?
Overrides the variant-resolved text/icon color.
final
variant → DraftModeUIButtonVariant
The color variant that determines background and text colors.
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