11import 'dart:async' ;
22
3- import 'package:flutter/material .dart' ;
3+ import 'package:flutter/widgets .dart' ;
44import 'package:flutter/services.dart' ;
55
6- import 'mixins/naked_mixins.dart' ; // your WidgetStatesMixin, etc.
6+ import 'mixins/naked_mixins.dart' ; // WidgetStatesMixin, FocusableMixin
77
8- /// Provides button interaction behavior without visual styling .
8+ /// A headless, focusable button that exposes interaction states .
99///
10- /// Users control presentation and semantics through the child or builder parameter.
10+ /// - No visuals are provided; pass a [child] or a [builder] to render UI.
11+ /// - Keyboard: Enter/Space activate the button. Optional [focusOnPress] .
12+ /// - Semantics: exposes a "button" role and supports [tooltip] /[semanticLabel] .
13+ /// - States: when using [builder] , you receive a `Set<WidgetState>` that
14+ /// reflects the current hovered/pressed/focused/disabled states.
15+ ///
16+ /// See also:
17+ /// - [NakedMenuItem] , which composes a menu item from [NakedButton] .
18+ /// - [FocusableActionDetector] , the underlying keyboard/hover integration.
19+ /// - [TextButton] , [ElevatedButton] , and [FilledButton] for Material-styled
20+ /// buttons when you don’t need a headless control.
1121class NakedButton extends StatefulWidget {
1222 const NakedButton ({
1323 super .key,
@@ -32,28 +42,60 @@ class NakedButton extends StatefulWidget {
3242 'Either child or builder must be provided' ,
3343 );
3444
45+ /// Visual contents of the button when not using [builder] .
3546 final Widget ? child;
47+
48+ /// Called when the button is activated (tap, Enter/Space).
3649 final VoidCallback ? onPressed;
50+
51+ /// Called when the button is long-pressed.
3752 final VoidCallback ? onLongPress;
53+
54+ /// Called when the button is double-tapped.
3855 final VoidCallback ? onDoubleTap;
3956
57+ /// Notifies when focus changes. Receives `true` when focused.
4058 final ValueChanged <bool >? onFocusChange;
59+
60+ /// Notifies when hover changes. Receives `true` when hovered.
4161 final ValueChanged <bool >? onHoverChange;
62+
63+ /// Notifies when pressed (highlight) changes. Receives `true` when down.
4264 final ValueChanged <bool >? onPressChange;
4365
66+ /// Builder that receives the current interaction [WidgetState] s.
67+ ///
68+ /// The signature is `(BuildContext, Set<WidgetState>, Widget? child)` .
69+ /// Use this to render custom visuals based on button state.
4470 final ValueWidgetBuilder <Set <WidgetState >>? builder;
4571
72+ /// Whether the button is enabled.
73+ ///
74+ /// The button is effectively enabled only if [enabled] is true and at least
75+ /// one handler among [onPressed] , [onLongPress] , or [onDoubleTap] is set.
4676 final bool enabled;
77+
78+ /// Mouse cursor when the button is enabled.
4779 final MouseCursor mouseCursor;
80+
81+ /// Whether to provide platform haptic/aural feedback on activation.
4882 final bool enableFeedback;
4983
84+ /// Optional external [FocusNode] to control focus ownership.
5085 final FocusNode ? focusNode;
86+
87+ /// Whether to autofocus this button on build.
5188 final bool autofocus;
5289
53- /// When true, pressing requests focus in addition to activating.
90+ /// Whether pressing requests focus in addition to activating.
5491 final bool focusOnPress;
5592
93+ /// Optional tooltip exposed to assistive technologies.
94+ ///
95+ /// Consider providing concise text; long labels are read verbosely.
5696 final String ? tooltip;
97+
98+ /// Optional semantic label announced by screen readers.
5799 final String ? semanticLabel;
58100
59101 // Consider button interactive if any handler is provided.
0 commit comments