textButton method
TextButton
textButton({
- required void onPressed()?,
- void onLongPress()?,
- void onHover()?,
- void onFocusChange()?,
- ButtonStyle? style,
- FocusNode? focusNode,
- bool autofocus = false,
- Clip? clipBehavior,
- WidgetStatesController? statesController,
- bool? isSemanticButton = true,
Creates a TextButton with this widget as its child.
Text buttons are low-emphasis buttons. They're typically used for less-important actions, including those located in dialogs and cards. In cards, text buttons help maintain an emphasis hierarchy.
Parameters:
onPressed
- Called when the button is pressed. If null, button is disabled.onLongPress
- Called when the button is long-pressed.onHover
- Called when a pointer enters or exits the button area.onFocusChange
- Called when the focus state of the button changes.style
- Customizes the button's appearance and behavior.focusNode
- An optional focus node to use as the focus node for this widget.autofocus
- Whether this widget should focus itself if nothing else is focused.clipBehavior
- The content will be clipped (or not) according to this option.statesController
- Represents the interactive state of the button.isSemanticButton
- Whether this button should be treated as a button by screen readers.
Returns a TextButton with this widget as its child.
Example:
Text('Learn More')
.textButton(
onPressed: () => showMoreInfo(),
style: TextButton.styleFrom(
foregroundColor: Colors.blue,
),
)
See also:
- TextButton, the underlying Material Design text button.
- textIconButton, for creating text buttons with icons.
Implementation
TextButton textButton({
required void Function()? onPressed,
void Function()? onLongPress,
void Function(bool)? onHover,
void Function(bool)? onFocusChange,
ButtonStyle? style,
FocusNode? focusNode,
bool autofocus = false,
Clip? clipBehavior,
WidgetStatesController? statesController,
bool? isSemanticButton = true,
}) =>
TextButton(
onPressed: onPressed,
onLongPress: onLongPress,
onHover: onHover,
onFocusChange: onFocusChange,
style: style,
focusNode: focusNode,
autofocus: autofocus,
clipBehavior: clipBehavior,
statesController: statesController,
isSemanticButton: isSemanticButton,
child: this,
);