File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -79,15 +79,12 @@ abstract class BaseSpinBoxState<T extends BaseSpinBox> extends State<T> {
7979 _controller = TextEditingController (text: _formatText (_value));
8080 _controller.addListener (_updateValue);
8181 _focusNode = widget.focusNode ?? FocusNode ();
82- _focusNode.addListener (() => setState (_selectAll));
83- _focusNode.addListener (() {
84- if (hasFocus) return ;
85- fixupValue (controller.text);
86- });
82+ _focusNode.addListener (_handleFocusChanged);
8783 }
8884
8985 @override
9086 void dispose () {
87+ _focusNode.removeListener (_handleFocusChanged);
9188 if (widget.focusNode == null ) {
9289 _focusNode.dispose ();
9390 }
@@ -153,8 +150,15 @@ abstract class BaseSpinBoxState<T extends BaseSpinBox> extends State<T> {
153150 }
154151 }
155152
153+ void _handleFocusChanged () {
154+ if (hasFocus) {
155+ setState (_selectAll);
156+ } else {
157+ fixupValue (_controller.text);
158+ }
159+ }
160+
156161 void _selectAll () {
157- if (! _focusNode.hasFocus) return ;
158162 _controller.selection = _controller.selection
159163 .copyWith (baseOffset: 0 , extentOffset: _controller.text.length);
160164 }
You can’t perform that action at this time.
0 commit comments