Clean leaks. (#142818)
diff --git a/packages/flutter/lib/src/material/range_slider.dart b/packages/flutter/lib/src/material/range_slider.dart
index 9496174..31ca2db 100644
--- a/packages/flutter/lib/src/material/range_slider.dart
+++ b/packages/flutter/lib/src/material/range_slider.dart
@@ -889,9 +889,9 @@
static const Duration _minimumInteractionTime = Duration(milliseconds: 500);
final _RangeSliderState _state;
- late Animation<double> _overlayAnimation;
- late Animation<double> _valueIndicatorAnimation;
- late Animation<double> _enableAnimation;
+ late CurvedAnimation _overlayAnimation;
+ late CurvedAnimation _valueIndicatorAnimation;
+ late CurvedAnimation _enableAnimation;
final TextPainter _startLabelPainter = TextPainter();
final TextPainter _endLabelPainter = TextPainter();
late HorizontalDragGestureRecognizer _drag;
@@ -1185,6 +1185,9 @@
_tap.dispose();
_startLabelPainter.dispose();
_endLabelPainter.dispose();
+ _enableAnimation.dispose();
+ _valueIndicatorAnimation.dispose();
+ _overlayAnimation.dispose();
super.dispose();
}
diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart
index 3d8680e..cdc6c02 100644
--- a/packages/flutter/lib/src/material/scaffold.dart
+++ b/packages/flutter/lib/src/material/scaffold.dart
@@ -1322,11 +1322,11 @@
// Controls the previous widget.child as it exits.
late AnimationController _previousController;
late Animation<double> _previousScaleAnimation;
- late Animation<double> _previousRotationAnimation;
+ late TrainHoppingAnimation _previousRotationAnimation;
// The animations to run, considering the widget's fabMoveAnimation and the current/previous entrance/exit animations.
late Animation<double> _currentScaleAnimation;
late Animation<double> _extendedCurrentScaleAnimation;
- late Animation<double> _currentRotationAnimation;
+ late TrainHoppingAnimation _currentRotationAnimation;
Widget? _previousChild;
@override
@@ -1353,6 +1353,7 @@
@override
void dispose() {
_previousController.dispose();
+ _disposeAnimations();
super.dispose();
}
@@ -1360,6 +1361,7 @@
void didUpdateWidget(_FloatingActionButtonTransition oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.fabMotionAnimator != widget.fabMotionAnimator || oldWidget.fabMoveAnimation != widget.fabMoveAnimation) {
+ _disposeAnimations();
// Get the right scale and rotation animations to use for this widget.
_updateAnimations();
}
@@ -1395,6 +1397,11 @@
end: 1.0,
).chain(CurveTween(curve: Curves.easeIn));
+ void _disposeAnimations() {
+ _previousRotationAnimation.dispose();
+ _currentRotationAnimation.dispose();
+ }
+
void _updateAnimations() {
// Get the animations for exit and entrance.
final CurvedAnimation previousExitScaleAnimation = CurvedAnimation(
diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart
index 4202503..37f96e3 100644
--- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart
+++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart
@@ -812,15 +812,16 @@
}
_stretchController = AnimationController(vsync: vsync)
..addStatusListener(_changePhase);
- final Animation<double> decelerator = CurvedAnimation(
+ _decelerator = CurvedAnimation(
parent: _stretchController,
curve: Curves.decelerate,
)..addListener(notifyListeners);
- _stretchSize = decelerator.drive(_stretchSizeTween);
+ _stretchSize = _decelerator.drive(_stretchSizeTween);
}
late final AnimationController _stretchController;
late final Animation<double> _stretchSize;
+ late final CurvedAnimation _decelerator;
final Tween<double> _stretchSizeTween = Tween<double>(begin: 0.0, end: 0.0);
_StretchState _state = _StretchState.idle;
@@ -923,6 +924,7 @@
@override
void dispose() {
_stretchController.dispose();
+ _decelerator.dispose();
super.dispose();
}
diff --git a/packages/flutter/test/animation/live_binding_test.dart b/packages/flutter/test/animation/live_binding_test.dart
index 33692e6..197175e 100644
--- a/packages/flutter/test/animation/live_binding_test.dart
+++ b/packages/flutter/test/animation/live_binding_test.dart
@@ -9,7 +9,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
/*
@@ -78,10 +77,7 @@
// Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588
}, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767
- testWidgets('Should show event indicator for pointer events with setSurfaceSize',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
- experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
- (WidgetTester tester) async {
+ testWidgets('Should show event indicator for pointer events with setSurfaceSize', (WidgetTester tester) async {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
addTearDown(animationSheet.dispose);
final List<Offset> taps = <Offset>[];
diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart
index fb66030..5601753 100644
--- a/packages/flutter/test/cupertino/refresh_test.dart
+++ b/packages/flutter/test/cupertino/refresh_test.dart
@@ -10,7 +10,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
late FakeBuilder mockHelper;
@@ -35,10 +34,7 @@
}
void uiTestGroup() {
- testWidgets("doesn't invoke anything without user interaction",
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
- experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
- (WidgetTester tester) async {
+ testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CustomScrollView(
diff --git a/packages/flutter/test/painting/decoration_image_lerp_test.dart b/packages/flutter/test/painting/decoration_image_lerp_test.dart
index fbdc039..8586abb 100644
--- a/packages/flutter/test/painting/decoration_image_lerp_test.dart
+++ b/packages/flutter/test/painting/decoration_image_lerp_test.dart
@@ -18,7 +18,7 @@
void main() {
testWidgets('ImageDecoration.lerp',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
+ // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
@@ -195,7 +195,7 @@
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
+ // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
@@ -416,7 +416,7 @@
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp with colored background',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
+ // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
diff --git a/packages/flutter/test/painting/image_stream_test.dart b/packages/flutter/test/painting/image_stream_test.dart
index e29cd45..ab1f51c 100644
--- a/packages/flutter/test/painting/image_stream_test.dart
+++ b/packages/flutter/test/painting/image_stream_test.dart
@@ -78,7 +78,7 @@
}
void main() {
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
+ // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
LeakTesting.settings = LeakTesting.settings.withIgnoredAll();
late Image image20x10;
diff --git a/packages/flutter/test/semantics/semantics_elevation_test.dart b/packages/flutter/test/semantics/semantics_elevation_test.dart
index b9d37d0..24c6918 100644
--- a/packages/flutter/test/semantics/semantics_elevation_test.dart
+++ b/packages/flutter/test/semantics/semantics_elevation_test.dart
@@ -5,15 +5,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart';
void main() {
- testWidgets('SemanticsNodes overlapping in z',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
- experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
- (WidgetTester tester) async {
+ testWidgets('SemanticsNodes overlapping in z', (WidgetTester tester) async {
// Cards are semantic boundaries that always own their own SemanticNode,
// PhysicalModels merge their semantics information into parent.
//
diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart
index 73eb1c1..567f2e3 100644
--- a/packages/flutter/test/widgets/basic_test.dart
+++ b/packages/flutter/test/widgets/basic_test.dart
@@ -15,16 +15,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
group('RawImage', () {
- testWidgets('properties',
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
- experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
- (WidgetTester tester) async {
+ testWidgets('properties', (WidgetTester tester) async {
final ui.Image image1 = (await tester.runAsync<ui.Image>(() => createTestImage()))!;
await tester.pumpWidget(