Skip to content

Commit 8bc6394

Browse files
wszakasonws
authored
fixed onSubmitted behavior and public State classes (ubuntu-flutter-community#86)
* call onSubmitted when losing focus * make State classes public * bugfix: fixup wasn't called when onSubmitted was null --------- Co-authored-by: md <[email protected]> Co-authored-by: ws <[email protected]>
1 parent 7f248cb commit 8bc6394

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/src/base_spin_box.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
164164
if (hasFocus) {
165165
_selectAll();
166166
} else {
167-
fixupValue(_controller.text);
167+
final value = fixupValue(_controller.text);
168+
widget.onSubmitted?.call(value);
168169
}
169170
});
170171
}

lib/src/cupertino/spin_box.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ class CupertinoSpinBox extends BaseSpinBox {
265265
final void Function(double)? onSubmitted;
266266

267267
@override
268-
State<CupertinoSpinBox> createState() => _CupertinoSpinBoxState();
268+
State<CupertinoSpinBox> createState() => CupertinoSpinBoxState();
269269
}
270270

271-
class _CupertinoSpinBoxState extends State<CupertinoSpinBox> with SpinBoxMixin {
271+
class CupertinoSpinBoxState extends State<CupertinoSpinBox> with SpinBoxMixin {
272272
@override
273273
Widget build(BuildContext context) {
274274
final isHorizontal = widget.direction == Axis.horizontal;

lib/src/material/spin_box.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ class SpinBox extends BaseSpinBox {
273273
final void Function(double)? onSubmitted;
274274

275275
@override
276-
State<SpinBox> createState() => _SpinBoxState();
276+
State<SpinBox> createState() => SpinBoxState();
277277
}
278278

279-
class _SpinBoxState extends State<SpinBox> with SpinBoxMixin {
279+
class SpinBoxState extends State<SpinBox> with SpinBoxMixin {
280280
Color? _iconColor(ThemeData theme, String? errorText) {
281281
if (!widget.enabled) return theme.disabledColor;
282282
if (hasFocus && errorText == null) return theme.colorScheme.primary;

0 commit comments

Comments
 (0)