CLPressable class

Primitivo di interazione condiviso — Foundation / Tier 0.

Traccia hover / press / focus / disabled una volta sola ed espone lo stato al builder, che decide il rendering. Sostituisce i tanti hand-roll di MouseRegion + _hovered bool sparsi nella libreria: ogni widget interattivo (bottoni, chip, voci nav, righe di tabella) si costruisce sopra questo.

Non impone visuali: motion e colori restano responsabilità del consumer (tipicamente via CLStyle + AnimatedContainer(duration: theme.durationFast)).

Gestisce anche l'attivazione da tastiera (Enter/Space, via ActivateIntent) e la semantica button per accessibilità — cose che i singoli hand-roll tipicamente dimenticano.

Esempio:

CLPressable(
  onTap: onTap,
  enabled: onTap != null,
  builder: (context, state) => AnimatedContainer(
    duration: theme.durationFast,
    color: state.hovered ? hoverColor : baseColor,
    child: child,
  ),
)
Inheritance
Available extensions

Constructors

CLPressable({Key? key, required CLPressableBuilder builder, VoidCallback? onTap, VoidCallback? onLongPress, VoidCallback? onTapDown, bool enabled = true, MouseCursor? cursor, FocusNode? focusNode, bool autofocus = false, HitTestBehavior behavior = HitTestBehavior.opaque, bool semanticButton = true, String? semanticLabel})
const

Properties

autofocus → bool
final
behavior → HitTestBehavior
final
builder → CLPressableBuilder
final
cursor → MouseCursor?
Override del cursore. Default: click se attivo e c'è un handler, altrimenti neutro.
final
enabled → bool
Quando false lo stato è disabled: niente hover/press/tap, cursore neutro.
final
focusNode → FocusNode?
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onLongPress → VoidCallback?
final
onTap → VoidCallback?
final
onTapDown → VoidCallback?
Chiamato al press-down (prima del tap), solo se enabled. Utile per un feedback immediato (es. HapticFeedback). Non implica attivazione.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticButton → bool
Espone Semantics(button: true). Metti false per elementi non-bottone (es. una riga solo-hover).
final
semanticLabel → String?
final

Methods

animateOnActionTrigger(AnimationInfo animationInfo, {bool hasBeenTriggered = false}) → Widget

Available on Widget, provided by the AnimatedWidgetExtension extension

animateOnPageLoad(AnimationInfo animationInfo) → Widget

Available on Widget, provided by the AnimatedWidgetExtension extension

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<CLPressable>
Creates the mutable state for this widget at a given location in the tree.
override
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