Fix slider notifies start and end twice when participates in gesture arena (#82152)
This commit is contained in:
parent
11edf36298
commit
0902576aba
@ -903,8 +903,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||||||
_tap = TapGestureRecognizer()
|
_tap = TapGestureRecognizer()
|
||||||
..team = team
|
..team = team
|
||||||
..onTapDown = _handleTapDown
|
..onTapDown = _handleTapDown
|
||||||
..onTapUp = _handleTapUp
|
..onTapUp = _handleTapUp;
|
||||||
..onTapCancel = _endInteraction;
|
|
||||||
_overlayAnimation = CurvedAnimation(
|
_overlayAnimation = CurvedAnimation(
|
||||||
parent: _state.overlayController,
|
parent: _state.overlayController,
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
@ -1224,7 +1223,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||||||
|
|
||||||
void _startInteraction(Offset globalPosition) {
|
void _startInteraction(Offset globalPosition) {
|
||||||
_state.showValueIndicator();
|
_state.showValueIndicator();
|
||||||
if (isInteractive) {
|
if (!_active && isInteractive) {
|
||||||
_active = true;
|
_active = true;
|
||||||
// We supply the *current* value as the start location, so that if we have
|
// We supply the *current* value as the start location, so that if we have
|
||||||
// a tap, it consists of a call to onChangeStart with the previous value and
|
// a tap, it consists of a call to onChangeStart with the previous value and
|
||||||
|
@ -908,6 +908,46 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Slider onChangeStart and onChangeEnd fire once', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/28115
|
||||||
|
|
||||||
|
int startFired = 0;
|
||||||
|
int endFired = 0;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: Material(
|
||||||
|
child: Center(
|
||||||
|
child: GestureDetector(
|
||||||
|
onHorizontalDragUpdate: (_) { },
|
||||||
|
child: Slider(
|
||||||
|
value: 0.0,
|
||||||
|
onChanged: (double newValue) { },
|
||||||
|
onChangeStart: (double value) {
|
||||||
|
startFired += 1;
|
||||||
|
},
|
||||||
|
onChangeEnd: (double value) {
|
||||||
|
endFired += 1;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.timedDrag(
|
||||||
|
find.byType(Slider),
|
||||||
|
const Offset(20.0, 0.0),
|
||||||
|
const Duration(milliseconds: 100),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(startFired, equals(1));
|
||||||
|
expect(endFired, equals(1));
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Slider sizing', (WidgetTester tester) async {
|
testWidgets('Slider sizing', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user