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 _RenderValueIndicator leak #147451

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
8 changes: 7 additions & 1 deletion packages/flutter/lib/src/material/slider.dart
Expand Up @@ -1868,7 +1868,7 @@ class _RenderValueIndicator extends RenderBox with RelayoutWhenSystemFontsChange
curve: Curves.fastOutSlowIn,
);
}
late Animation<double> _valueIndicatorAnimation;
late CurvedAnimation _valueIndicatorAnimation;
_SliderState _state;

@override
Expand Down Expand Up @@ -1897,6 +1897,12 @@ class _RenderValueIndicator extends RenderBox with RelayoutWhenSystemFontsChange
Size computeDryLayout(BoxConstraints constraints) {
return constraints.smallest;
}

@override
void dispose() {
_valueIndicatorAnimation.dispose();
super.dispose();
}
}

class _SliderDefaultsM2 extends SliderThemeData {
Expand Down
6 changes: 5 additions & 1 deletion packages/flutter/test/material/slider_test.dart
Expand Up @@ -13,6 +13,7 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/physics/utils.dart' show nearEqual;
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

import '../widgets/semantics_tester.dart';

Expand Down Expand Up @@ -140,7 +141,10 @@ void main() {
expect(log[0], const Offset(212.0, 300.0));
});

testWidgets('Slider can move when tapped (LTR)', (WidgetTester tester) async {
testWidgets(
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: <String>['CurvedAnimation']),
'Slider can move when tapped (LTR)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey();
double value = 0.0;
double? startValue;
Expand Down