Skip to content

Commit 2e2b60a

Browse files
authored
Call onSubmitted when step buttons are pressed (ubuntu-flutter-community#81)
1 parent 36ba882 commit 2e2b60a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/src/base_spin_box.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ abstract class BaseSpinBox extends StatefulWidget {
3737
double get value;
3838
int get decimals;
3939
int get digits;
40+
void Function(double)? get onSubmitted;
4041
ValueChanged<double>? get onChanged;
4142
bool Function(double value)? get canChange;
4243
VoidCallback? get beforeChange;
@@ -127,6 +128,7 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
127128

128129
widget.beforeChange?.call();
129130
setState(() => _updateController(value, newValue));
131+
widget.onSubmitted?.call(double.parse(_formatText(newValue)));
130132
widget.afterChange?.call();
131133
}
132134

lib/src/cupertino/spin_box.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,12 @@ class CupertinoSpinBox extends BaseSpinBox {
256256
/// See [CupertinoTextField.toolbarOptions].
257257
final ToolbarOptions? toolbarOptions;
258258

259-
/// See [CupertinoTextField.onSubmitted]. Is called with a formatted value.
259+
/// See [TextField.onSubmitted].
260+
///
261+
/// Is also called when an increment or decrement button is pressed.
262+
///
263+
/// Value is formatted.
264+
@override
260265
final void Function(double)? onSubmitted;
261266

262267
@override

lib/src/material/spin_box.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ class SpinBox extends BaseSpinBox {
264264
/// See [TextField.toolbarOptions].
265265
final ToolbarOptions? toolbarOptions;
266266

267-
/// See [TextField.onSubmitted]. Is called with a formatted value.
267+
/// See [TextField.onSubmitted].
268+
///
269+
/// Is also called when an increment or decrement button is pressed.
270+
///
271+
/// Value is formatted.
272+
@override
268273
final void Function(double)? onSubmitted;
269274

270275
@override

0 commit comments

Comments
 (0)