Fix RangeSlider notifies start and end twice when participates in gesture arena (#128674)
Fixes https://github.com/flutter/flutter/issues/128433 This PR applies the same fix as we did for Slider https://github.com/flutter/flutter/pull/82152
This commit is contained in:
parent
05d1cde0dd
commit
ad8c997817
@ -833,7 +833,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
|
||||
..team = team
|
||||
..onTapDown = _handleTapDown
|
||||
..onTapUp = _handleTapUp
|
||||
..onTapCancel = _handleTapCancel
|
||||
..gestureSettings = gestureSettings;
|
||||
_overlayAnimation = CurvedAnimation(
|
||||
parent: _state.overlayController,
|
||||
@ -1221,6 +1220,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
|
||||
}
|
||||
|
||||
void _startInteraction(Offset globalPosition) {
|
||||
if (_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
_state.showValueIndicator();
|
||||
final double tapValue = clampDouble(_getValueFromGlobalPosition(globalPosition), 0.0, 1.0);
|
||||
_lastThumbSelection = sliderTheme.thumbSelector!(textDirection, values, tapValue, _thumbSize, size, 0);
|
||||
@ -1333,10 +1336,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
|
||||
_endInteraction();
|
||||
}
|
||||
|
||||
void _handleTapCancel() {
|
||||
_endInteraction();
|
||||
}
|
||||
|
||||
@override
|
||||
bool hitTestSelf(Offset position) => true;
|
||||
|
||||
|
@ -2540,4 +2540,45 @@ void main() {
|
||||
isNot(paints..circle(color: draggedColor)),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('RangeSlider onChangeStart and onChangeEnd fire once', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/128433
|
||||
|
||||
int startFired = 0;
|
||||
int endFired = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Material(
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onHorizontalDragUpdate: (_) { },
|
||||
child: RangeSlider(
|
||||
values: const RangeValues(40, 80),
|
||||
max: 100,
|
||||
onChanged: (RangeValues newValue) { },
|
||||
onChangeStart: (RangeValues value) {
|
||||
startFired += 1;
|
||||
},
|
||||
onChangeEnd: (RangeValues value) {
|
||||
endFired += 1;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.timedDragFrom(
|
||||
tester.getTopLeft(find.byType(RangeSlider)),
|
||||
const Offset(100.0, 0.0),
|
||||
const Duration(milliseconds: 500),
|
||||
);
|
||||
|
||||
expect(startFired, equals(1));
|
||||
expect(endFired, equals(1));
|
||||
});
|
||||
}
|
||||
|
@ -1644,7 +1644,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('ListWheelScrollView does not crash and does not allow taps on children that were laid out, but not painted', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/12649
|
||||
// Regression test for https://github.com/flutter/flutter/issues/126491
|
||||
|
||||
final FixedExtentScrollController controller = FixedExtentScrollController();
|
||||
final List<int> children = List<int>.generate(100, (int index) => index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user