Fix render problem on Slider (#15039)
Fixes a small rendering problem when dragging the slider, as well as a couple of small bugs (de-duping of value changes, and actually using a parameter passed to _unlerp).
This commit is contained in:
parent
b90659cd30
commit
a1d2443e7b
@ -239,8 +239,10 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
void _handleChanged(double value) {
|
void _handleChanged(double value) {
|
||||||
assert(widget.onChanged != null);
|
assert(widget.onChanged != null);
|
||||||
final double transformedValue = _lerp(value);
|
final double lerpValue = _lerp(value);
|
||||||
widget.onChanged(transformedValue);
|
if (lerpValue != widget.value) {
|
||||||
|
widget.onChanged(lerpValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a number between min and max, proportional to value, which must
|
// Returns a number between min and max, proportional to value, which must
|
||||||
@ -255,7 +257,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||||||
double _unlerp(double value) {
|
double _unlerp(double value) {
|
||||||
assert(value <= widget.max);
|
assert(value <= widget.max);
|
||||||
assert(value >= widget.min);
|
assert(value >= widget.min);
|
||||||
return widget.max > widget.min ? (widget.value - widget.min) / (widget.max - widget.min) : 0.0;
|
return widget.max > widget.min ? (value - widget.min) / (widget.max - widget.min) : 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -380,12 +382,13 @@ class _RenderSlider extends RenderBox {
|
|||||||
..team = team
|
..team = team
|
||||||
..onStart = _handleDragStart
|
..onStart = _handleDragStart
|
||||||
..onUpdate = _handleDragUpdate
|
..onUpdate = _handleDragUpdate
|
||||||
..onEnd = _handleDragEnd;
|
..onEnd = _handleDragEnd
|
||||||
|
..onCancel = _endInteraction;
|
||||||
_tap = new TapGestureRecognizer()
|
_tap = new TapGestureRecognizer()
|
||||||
..team = team
|
..team = team
|
||||||
..onTapCancel = _endInteraction
|
|
||||||
..onTapDown = _handleTapDown
|
..onTapDown = _handleTapDown
|
||||||
..onTapUp = _handleTapUp;
|
..onTapUp = _handleTapUp
|
||||||
|
..onTapCancel = _endInteraction;
|
||||||
_reaction = new CurvedAnimation(parent: state.reactionController, curve: Curves.fastOutSlowIn)
|
_reaction = new CurvedAnimation(parent: state.reactionController, curve: Curves.fastOutSlowIn)
|
||||||
..addListener(markNeedsPaint);
|
..addListener(markNeedsPaint);
|
||||||
state.enableController.value = isInteractive ? 1.0 : 0.0;
|
state.enableController.value = isInteractive ? 1.0 : 0.0;
|
||||||
@ -586,6 +589,7 @@ class _RenderSlider extends RenderBox {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
onChanged(_discretize(_currentDragValue));
|
onChanged(_discretize(_currentDragValue));
|
||||||
|
markNeedsPaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user