Skip to content

Commit

Permalink
Fix memory leak in Form (#132987)
Browse files Browse the repository at this point in the history
Diposes some restorable variables that weren't disposed before.
  • Loading branch information
justinmc authored Aug 22, 2023
1 parent b3005a3 commit 0278671
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/flutter/lib/src/widgets/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ class FormFieldState<T> extends State<FormField<T>> with RestorationMixin {
super.deactivate();
}

@override
void dispose() {
_errorText.dispose();
_hasInteractedByUser.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
if (widget.enabled) {
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter/test/material/text_form_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ void main() {
},
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.linux, TargetPlatform.windows }),
skip: kIsWeb, // [intended] we don't supply the cut/copy/paste buttons on the web.
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/130467
leakTrackingTestConfig: const LeakTrackingTestConfig(allowAllNotDisposed: true, allowAllNotGCed: true),
);

testWidgetsWithLeakTracking(
Expand Down

0 comments on commit 0278671

Please sign in to comment.