diff --git a/packages/flutter/lib/src/cupertino/text_form_field_row.dart b/packages/flutter/lib/src/cupertino/text_form_field_row.dart index ed20b583a5fc..674c62237ed5 100644 --- a/packages/flutter/lib/src/cupertino/text_form_field_row.dart +++ b/packages/flutter/lib/src/cupertino/text_form_field_row.dart @@ -313,6 +313,7 @@ class _CupertinoTextFormFieldRowState extends FormFieldState { @override void dispose() { _cupertinoTextFormFieldRow.controller?.removeListener(_handleControllerChanged); + _controller?.dispose(); super.dispose(); } diff --git a/packages/flutter/test/cupertino/form_section_test.dart b/packages/flutter/test/cupertino/form_section_test.dart index 7a9e4f0539b3..da86fb9e898c 100644 --- a/packages/flutter/test/cupertino/form_section_test.dart +++ b/packages/flutter/test/cupertino/form_section_test.dart @@ -5,9 +5,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; void main() { - testWidgets('Shows header', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Shows header', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -22,7 +23,7 @@ void main() { expect(find.text('Header'), findsOneWidget); }); - testWidgets('Shows footer', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Shows footer', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -37,7 +38,7 @@ void main() { expect(find.text('Footer'), findsOneWidget); }); - testWidgets('Shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -54,7 +55,7 @@ void main() { expect(childrenColumn.children.length, 3); }); - testWidgets('Shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -75,7 +76,7 @@ void main() { expect(childrenColumn.children.length, 5); }); - testWidgets('Does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -93,7 +94,7 @@ void main() { expect(childrenColumn.children.length, 1); }); - testWidgets('Does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( restorationScopeId: 'App', @@ -115,7 +116,7 @@ void main() { expect(childrenColumn.children.length, 3); }); - testWidgets('Sets background color for section', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Sets background color for section', (WidgetTester tester) async { const Color backgroundColor = CupertinoColors.systemBlue; await tester.pumpWidget( @@ -138,7 +139,7 @@ void main() { expect(boxDecoration.color, backgroundColor); }); - testWidgets('Setting clipBehavior clips children section', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Setting clipBehavior clips children section', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center( @@ -153,7 +154,7 @@ void main() { expect(find.byType(ClipRRect), findsOneWidget); }); - testWidgets('Not setting clipBehavior does not produce a RenderClipRRect object', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Not setting clipBehavior does not produce a RenderClipRRect object', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: Center(