onFocused method
T
onFocused(
- T style
Creates a variant for focused state.
Note: Focus state tracking requires the widget to be wrapped with Pressable or use PressableBox. Unlike onHovered and onPressed, which work automatically with any styled widget, focus handling needs the Pressable widget.
Example:
// Focus variant only activates when wrapped with Pressable
Pressable(
child: Box(
style: BoxStyler().onFocused(.new().color(Colors.green))
),
)
// Or use PressableBox directly
PressableBox(
style: BoxStyler().onFocused(.new().color(Colors.green)),
child: child,
)
Implementation
T onFocused(T style) {
return variant(ContextVariant.widgetState(.focused), style);
}