Skip to content

Commit 524c17e

Browse files
committed
Move steps back
1 parent b6b5a7e commit 524c17e

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

lib/src/base_spin_box.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,34 @@ mixin SpinBoxMixin<T extends BaseSpinBox> on State<T> {
5454
FocusNode get focusNode => _focusNode;
5555
SpinFormatter get formatter => SpinFormatter(_controller);
5656

57-
String _formatValue(double value) {
58-
return formatter.formatValue(value,
59-
decimals: widget.decimals, digits: widget.digits);
60-
}
61-
6257
Map<ShortcutActivator, VoidCallback> get bindings {
6358
return {
6459
// ### TODO: use SingleActivator fixed in Flutter 2.10+
6560
// https://github.com/flutter/flutter/issues/92717
66-
LogicalKeySet(LogicalKeyboardKey.arrowUp): _controller.stepUp,
67-
LogicalKeySet(LogicalKeyboardKey.arrowDown): _controller.stepDown,
68-
LogicalKeySet(LogicalKeyboardKey.pageUp): _controller.pageStepUp,
69-
LogicalKeySet(LogicalKeyboardKey.pageDown): _controller.pageStepDown,
61+
LogicalKeySet(LogicalKeyboardKey.arrowUp): _stepUp,
62+
LogicalKeySet(LogicalKeyboardKey.arrowDown): _stepDown,
63+
LogicalKeySet(LogicalKeyboardKey.pageUp): _pageStepUp,
64+
LogicalKeySet(LogicalKeyboardKey.pageDown): _pageStepDown,
7065
};
7166
}
7267

68+
String _formatValue(double value) {
69+
return formatter.formatValue(value,
70+
decimals: widget.decimals, digits: widget.digits);
71+
}
72+
73+
void _stepUp() => controller.value += widget.step;
74+
void _stepDown() => controller.value += -widget.step;
75+
void _pageStepUp() => controller.value += widget.pageStep;
76+
void _pageStepDown() => controller.value -= widget.pageStep;
77+
7378
@override
7479
void initState() {
7580
super.initState();
7681
_controller = widget.controller ??
7782
SpinController(
7883
min: widget.min,
7984
max: widget.max,
80-
step: widget.step,
81-
pageStep: widget.pageStep,
8285
value: widget.value,
8386
decimals: widget.decimals,
8487
);

lib/src/spin_controller.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class SpinController extends ValueNotifier<double> {
2727
required double min,
2828
required double max,
2929
required double value,
30-
this.step = 1,
31-
this.pageStep,
3230
this.decimals = 0,
3331
}) : _min = min,
3432
_max = max,
@@ -37,8 +35,6 @@ class SpinController extends ValueNotifier<double> {
3735
double _min;
3836
double _max;
3937

40-
final double step;
41-
final double? pageStep;
4238
final int decimals;
4339

4440
double get min => _min;
@@ -66,11 +62,6 @@ class SpinController extends ValueNotifier<double> {
6662
return int.tryParse(text)?.toDouble();
6763
}
6864

69-
void stepUp() => value += step;
70-
void stepDown() => value += -step;
71-
void pageStepUp() => value += pageStep ?? 0;
72-
void pageStepDown() => value -= pageStep ?? 0;
73-
7465
bool canChange(double value) => true;
7566

7667
@override

0 commit comments

Comments
 (0)