@@ -52,7 +52,12 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
5252 SpinController get controller => _controller;
5353 TextEditingController get editor => _editor;
5454 FocusNode get focusNode => _focusNode;
55- TextInputFormatter get formatter => SpinFormatter (_controller);
55+ SpinFormatter get formatter => SpinFormatter (_controller);
56+
57+ String _formatValue (double value) {
58+ return formatter.formatValue (value,
59+ decimals: widget.decimals, digits: widget.digits);
60+ }
5661
5762 Map <ShortcutActivator , VoidCallback > get bindings {
5863 return {
@@ -76,10 +81,9 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
7681 pageStep: widget.pageStep,
7782 value: widget.value,
7883 decimals: widget.decimals,
79- digits: widget.digits,
8084 );
8185 _controller.addListener (_handleValueChange);
82- _editor = TextEditingController (text: _controller. format (widget.value));
86+ _editor = TextEditingController (text: _formatValue (widget.value));
8387 _editor.addListener (_handleTextChange);
8488 _focusNode = widget.focusNode ?? FocusNode ();
8589 _focusNode.addListener (_handleFocusChange);
@@ -112,7 +116,7 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
112116 }
113117
114118 void _updateText (double newValue) {
115- final text = _controller. format (newValue);
119+ final text = _formatValue (newValue);
116120 final selection = _editor.selection;
117121 final oldOffset = _controller.value.isNegative ? 1 : 0 ;
118122 final newOffset = _controller.parse (text)? .isNegative == true ? 1 : 0 ;
@@ -130,7 +134,7 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
130134 void fixupValue (String text) {
131135 final v = _controller.parse (text);
132136 if (v == null ) {
133- _editor.text = _controller. format (_controller.value);
137+ _editor.text = _formatValue (_controller.value);
134138 } else if (v < _controller.min || v > _controller.max) {
135139 _controller.value = v.clamp (_controller.min, _controller.max);
136140 }
0 commit comments