knobKeyDown method
Handles key press events on either slider knob.
isLeftKnob
true indicates that the event ocurred on the left knob.
Implementation
void knobKeyDown(KeyboardEvent event, {bool isLeftKnobPressed = false}) {
if (disabled) return;
var currValue = isLeftKnobPressed ? leftValue : value;
var newValue = currValue;
final bigStepSize = ((max - min) / 10.0).ceil();
final sign = isRtl ? -1 : 1;
switch (event.keyCode) {
case KeyCode.DOWN:
case KeyCode.LEFT:
newValue = math.max(min, math.min(max, currValue - step * sign));
break;
case KeyCode.UP:
case KeyCode.RIGHT:
newValue = math.max(min, math.min(max, currValue + step * sign));
break;
case KeyCode.PAGE_UP:
newValue = math.max(min, math.min(max, currValue + step * bigStepSize));
break;
case KeyCode.PAGE_DOWN:
newValue = math.max(min, math.min(max, currValue - step * bigStepSize));
break;
}
if (isLeftKnobPressed) {
if (newValue != leftValue) {
leftValue =
_getValidLeftValue(value as double, newValue as double) as int;
_leftChangeController.add(leftValue);
}
} else if (newValue != value) {
value = _getValidRightValue(leftValue as double, newValue as double);
_changeController.add(value);
}
}