Skip to content

Commit 39befd8

Browse files
authored
Clean leaks. (#142818)
1 parent a2c7ed9 commit 39befd8

File tree

9 files changed

+27
-31
lines changed

9 files changed

+27
-31
lines changed

packages/flutter/lib/src/material/range_slider.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
889889
static const Duration _minimumInteractionTime = Duration(milliseconds: 500);
890890

891891
final _RangeSliderState _state;
892-
late Animation<double> _overlayAnimation;
893-
late Animation<double> _valueIndicatorAnimation;
894-
late Animation<double> _enableAnimation;
892+
late CurvedAnimation _overlayAnimation;
893+
late CurvedAnimation _valueIndicatorAnimation;
894+
late CurvedAnimation _enableAnimation;
895895
final TextPainter _startLabelPainter = TextPainter();
896896
final TextPainter _endLabelPainter = TextPainter();
897897
late HorizontalDragGestureRecognizer _drag;
@@ -1185,6 +1185,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
11851185
_tap.dispose();
11861186
_startLabelPainter.dispose();
11871187
_endLabelPainter.dispose();
1188+
_enableAnimation.dispose();
1189+
_valueIndicatorAnimation.dispose();
1190+
_overlayAnimation.dispose();
11881191
super.dispose();
11891192
}
11901193

packages/flutter/lib/src/material/scaffold.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,11 +1322,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
13221322
// Controls the previous widget.child as it exits.
13231323
late AnimationController _previousController;
13241324
late Animation<double> _previousScaleAnimation;
1325-
late Animation<double> _previousRotationAnimation;
1325+
late TrainHoppingAnimation _previousRotationAnimation;
13261326
// The animations to run, considering the widget's fabMoveAnimation and the current/previous entrance/exit animations.
13271327
late Animation<double> _currentScaleAnimation;
13281328
late Animation<double> _extendedCurrentScaleAnimation;
1329-
late Animation<double> _currentRotationAnimation;
1329+
late TrainHoppingAnimation _currentRotationAnimation;
13301330
Widget? _previousChild;
13311331

13321332
@override
@@ -1353,13 +1353,15 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
13531353
@override
13541354
void dispose() {
13551355
_previousController.dispose();
1356+
_disposeAnimations();
13561357
super.dispose();
13571358
}
13581359

13591360
@override
13601361
void didUpdateWidget(_FloatingActionButtonTransition oldWidget) {
13611362
super.didUpdateWidget(oldWidget);
13621363
if (oldWidget.fabMotionAnimator != widget.fabMotionAnimator || oldWidget.fabMoveAnimation != widget.fabMoveAnimation) {
1364+
_disposeAnimations();
13631365
// Get the right scale and rotation animations to use for this widget.
13641366
_updateAnimations();
13651367
}
@@ -1395,6 +1397,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
13951397
end: 1.0,
13961398
).chain(CurveTween(curve: Curves.easeIn));
13971399

1400+
void _disposeAnimations() {
1401+
_previousRotationAnimation.dispose();
1402+
_currentRotationAnimation.dispose();
1403+
}
1404+
13981405
void _updateAnimations() {
13991406
// Get the animations for exit and entrance.
14001407
final CurvedAnimation previousExitScaleAnimation = CurvedAnimation(

packages/flutter/lib/src/widgets/overscroll_indicator.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,15 +812,16 @@ class _StretchController extends ChangeNotifier {
812812
}
813813
_stretchController = AnimationController(vsync: vsync)
814814
..addStatusListener(_changePhase);
815-
final Animation<double> decelerator = CurvedAnimation(
815+
_decelerator = CurvedAnimation(
816816
parent: _stretchController,
817817
curve: Curves.decelerate,
818818
)..addListener(notifyListeners);
819-
_stretchSize = decelerator.drive(_stretchSizeTween);
819+
_stretchSize = _decelerator.drive(_stretchSizeTween);
820820
}
821821

822822
late final AnimationController _stretchController;
823823
late final Animation<double> _stretchSize;
824+
late final CurvedAnimation _decelerator;
824825
final Tween<double> _stretchSizeTween = Tween<double>(begin: 0.0, end: 0.0);
825826
_StretchState _state = _StretchState.idle;
826827

@@ -923,6 +924,7 @@ class _StretchController extends ChangeNotifier {
923924
@override
924925
void dispose() {
925926
_stretchController.dispose();
927+
_decelerator.dispose();
926928
super.dispose();
927929
}
928930

packages/flutter/test/animation/live_binding_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ library;
99

1010
import 'package:flutter/material.dart';
1111
import 'package:flutter_test/flutter_test.dart';
12-
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1312

1413
void main() {
1514
/*
@@ -78,10 +77,7 @@ void main() {
7877
// Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588
7978
}, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767
8079

81-
testWidgets('Should show event indicator for pointer events with setSurfaceSize',
82-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
83-
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
84-
(WidgetTester tester) async {
80+
testWidgets('Should show event indicator for pointer events with setSurfaceSize', (WidgetTester tester) async {
8581
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
8682
addTearDown(animationSheet.dispose);
8783
final List<Offset> taps = <Offset>[];

packages/flutter/test/cupertino/refresh_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:flutter/cupertino.dart';
1010
import 'package:flutter/foundation.dart';
1111
import 'package:flutter/services.dart';
1212
import 'package:flutter_test/flutter_test.dart';
13-
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1413

1514
void main() {
1615
late FakeBuilder mockHelper;
@@ -35,10 +34,7 @@ void main() {
3534
}
3635

3736
void uiTestGroup() {
38-
testWidgets("doesn't invoke anything without user interaction",
39-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
40-
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
41-
(WidgetTester tester) async {
37+
testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async {
4238
await tester.pumpWidget(
4339
CupertinoApp(
4440
home: CustomScrollView(

packages/flutter/test/painting/decoration_image_lerp_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1818

1919
void main() {
2020
testWidgets('ImageDecoration.lerp',
21-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
21+
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
2222
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
2323
(WidgetTester tester) async {
2424
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
@@ -195,7 +195,7 @@ void main() {
195195
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
196196

197197
testWidgets('ImageDecoration.lerp',
198-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
198+
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
199199
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
200200
(WidgetTester tester) async {
201201
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
@@ -416,7 +416,7 @@ void main() {
416416
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
417417

418418
testWidgets('ImageDecoration.lerp with colored background',
419-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
419+
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
420420
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
421421
(WidgetTester tester) async {
422422
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[

packages/flutter/test/painting/image_stream_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
7878
}
7979

8080
void main() {
81-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
81+
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
8282
LeakTesting.settings = LeakTesting.settings.withIgnoredAll();
8383

8484
late Image image20x10;

packages/flutter/test/semantics/semantics_elevation_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
import 'package:flutter/material.dart';
66
import 'package:flutter/rendering.dart';
77
import 'package:flutter_test/flutter_test.dart';
8-
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
98

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

1211
void main() {
13-
testWidgets('SemanticsNodes overlapping in z',
14-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
15-
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
16-
(WidgetTester tester) async {
12+
testWidgets('SemanticsNodes overlapping in z', (WidgetTester tester) async {
1713
// Cards are semantic boundaries that always own their own SemanticNode,
1814
// PhysicalModels merge their semantics information into parent.
1915
//

packages/flutter/test/widgets/basic_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ import 'package:flutter/gestures.dart';
1515
import 'package:flutter/material.dart';
1616
import 'package:flutter/rendering.dart';
1717
import 'package:flutter_test/flutter_test.dart';
18-
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1918

2019
import 'semantics_tester.dart';
2120

2221
void main() {
2322
group('RawImage', () {
24-
testWidgets('properties',
25-
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
26-
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
27-
(WidgetTester tester) async {
23+
testWidgets('properties', (WidgetTester tester) async {
2824
final ui.Image image1 = (await tester.runAsync<ui.Image>(() => createTestImage()))!;
2925

3026
await tester.pumpWidget(

0 commit comments

Comments
 (0)