File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ abstract class BaseSpinBox extends StatefulWidget {
3838 int get decimals;
3939 int get digits;
4040 ValueChanged <double >? get onChanged;
41- void Function (double value)? get onSubmitted;
4241 bool Function (double value)? get canChange;
4342 VoidCallback ? get beforeChange;
4443 VoidCallback ? get afterChange;
@@ -147,15 +146,15 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
147146 }
148147
149148 @protected
150- void fixupValue (String value) {
149+ double fixupValue (String value) {
151150 final v = _parseValue (value);
152151 if (value.isEmpty || (v < widget.min || v > widget.max)) {
153152 // will trigger notify to _updateValue()
154153 _controller.text = _formatText (_cachedValue);
155154 } else {
156155 _cachedValue = _value;
157156 }
158- widget.onSubmitted ? . call ( _cachedValue) ;
157+ return _cachedValue;
159158 }
160159
161160 void _handleFocusChanged () {
Original file line number Diff line number Diff line change @@ -257,7 +257,6 @@ class CupertinoSpinBox extends BaseSpinBox {
257257 final ToolbarOptions ? toolbarOptions;
258258
259259 /// See [CupertinoTextField.onSubmitted] . Is called with a formatted value.
260- @override
261260 final void Function (double )? onSubmitted;
262261
263262 @override
@@ -311,7 +310,10 @@ class _CupertinoSpinBoxState extends State<CupertinoSpinBox> with SpinBoxMixin {
311310 enabled: widget.enabled,
312311 readOnly: widget.readOnly,
313312 focusNode: focusNode,
314- onSubmitted: fixupValue,
313+ onSubmitted: (v) {
314+ final value = fixupValue (v);
315+ widget.onSubmitted? .call (value);
316+ },
315317 ),
316318 );
317319
Original file line number Diff line number Diff line change @@ -265,7 +265,6 @@ class SpinBox extends BaseSpinBox {
265265 final ToolbarOptions ? toolbarOptions;
266266
267267 /// See [TextField.onSubmitted] . Is called with a formatted value.
268- @override
269268 final void Function (double )? onSubmitted;
270269
271270 @override
@@ -416,7 +415,10 @@ class _SpinBoxState extends State<SpinBox> with SpinBoxMixin {
416415 enabled: widget.enabled,
417416 readOnly: widget.readOnly,
418417 focusNode: focusNode,
419- onSubmitted: fixupValue,
418+ onSubmitted: (v) {
419+ final value = fixupValue (v);
420+ widget.onSubmitted? .call (value);
421+ },
420422 ),
421423 );
422424
You can’t perform that action at this time.
0 commit comments