Fix _RenderValueIndicator leak (#147451)

This commit is contained in:
Dimil Kalathiya 2024-04-28 06:00:58 +05:30 committed by GitHub
parent f9933b6994
commit 1189d44240
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -1868,7 +1868,7 @@ class _RenderValueIndicator extends RenderBox with RelayoutWhenSystemFontsChange
curve: Curves.fastOutSlowIn,
);
}
late Animation<double> _valueIndicatorAnimation;
late CurvedAnimation _valueIndicatorAnimation;
_SliderState _state;
@override
@ -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 {

View File

@ -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';
@ -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;