_RenderValueIndicator leak fix used on RangeSlider (#147581)

Part of #141198
*Fixes memory leak on `RangeSlider`*
This commit is contained in:
Dimil Kalathiya
2024-05-09 00:34:17 +05:30
committed by GitHub
parent 32444e5822
commit c97f22ec12
2 changed files with 12 additions and 2 deletions

View File

@@ -1787,7 +1787,7 @@ class _RenderValueIndicator extends RenderBox with RelayoutWhenSystemFontsChange
);
}
late Animation<double> _valueIndicatorAnimation;
late CurvedAnimation _valueIndicatorAnimation;
late _RangeSliderState _state;
@override
@@ -1819,4 +1819,10 @@ class _RenderValueIndicator extends RenderBox with RelayoutWhenSystemFontsChange
Size computeDryLayout(BoxConstraints constraints) {
return constraints.smallest;
}
@override
void dispose() {
_valueIndicatorAnimation.dispose();
super.dispose();
}
}

View File

@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.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';
@@ -119,7 +120,10 @@ void main() {
expect(dragStarted, false);
});
testWidgets('Range Slider can move when tapped (continuous LTR)', (WidgetTester tester) async {
testWidgets('Range Slider can move when tapped (continuous LTR)',
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: <String>['CurvedAnimation']),
(WidgetTester tester) async {
RangeValues values = const RangeValues(0.3, 0.7);
await tester.pumpWidget(