Skip to content

Commit

Permalink
Fix memory leak in ExpansionTile. (#147596)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksokolovskyi authored May 5, 2024
1 parent eeb351c commit 145e940
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/flutter/lib/src/material/expansion_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
void dispose() {
_tileController._state = null;
_animationController.dispose();
_heightFactor.dispose();
_timer?.cancel();
_timer = null;
super.dispose();
Expand Down
6 changes: 5 additions & 1 deletion packages/flutter/test/material/expansion_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:flutter/foundation.dart';
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';

class TestIcon extends StatefulWidget {
const TestIcon({super.key});
Expand Down Expand Up @@ -222,7 +223,10 @@ void main() {
expect(iconColor(collapsedIconKey), foregroundColor);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));

testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
testWidgets('ExpansionTile subtitle',
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: const <String>['CurvedAnimation']),
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
Expand Down

0 comments on commit 145e940

Please sign in to comment.