Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RangeSlider throws an exception in a ListView #135667

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/range_slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
late TapGestureRecognizer _tap;
bool _active = false;
late RangeValues _newValues;
late Offset _startThumbCenter;
late Offset _endThumbCenter;
Offset _startThumbCenter = Offset.zero;
Offset _endThumbCenter = Offset.zero;
Rect? overlayStartRect;
Rect? overlayEndRect;

Expand Down
32 changes: 31 additions & 1 deletion packages/flutter/test/material/range_slider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ void main() {
);
});

testWidgetsWithLeakTracking('RangeSlider onChangeStart and onChangeEnd fire once', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RangeSlider onChangeStart and onChangeEnd fire once', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/128433

int startFired = 0;
Expand Down Expand Up @@ -2581,4 +2581,34 @@ void main() {
expect(startFired, equals(1));
expect(endFired, equals(1));
});

testWidgetsWithLeakTracking('RangeSlider in a ListView does not throw an exception', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/126648

await tester.pumpWidget(
MaterialApp(
home: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: ListView(
children: <Widget>[
const SizedBox(
height: 600,
child: Placeholder(),
),
RangeSlider(
values: const RangeValues(40, 80),
max: 100,
onChanged: (RangeValues newValue) { },
),
],
),
),
),
),
);

// No exception should be thrown.
expect(tester.takeException(), null);
});
}