Skip to content

Commit 67470e1

Browse files
authored
Dispose OverlayEntry in WidgetsApp.router semantics tree structure test (flutter#192995)
In flutter#192601, the `'WidgetsApp.router produces expected semantics tree structure'` test added in `packages/flutter/test/widgets/app_test.dart` registered `addTearDown(entry.remove)` for its `OverlayEntry` without calling `entry.dispose()`. Because `OverlayEntry` allocates an internal `ValueNotifier<_OverlayEntryWidgetState?>` that is only disposed in `OverlayEntry.dispose()`, `Windows framework_tests_widgets_leak_tracking` failed in `tearDownAll` with 2 undisposed objects (`OverlayEntry` and `ValueNotifier<_OverlayEntryWidgetState?>`). This change updates the tear-down callback to call both `entry.remove()` and `entry.dispose()`, matching `packages/flutter/test/widgets/overlay_test.dart`. Fixes flutter#192993 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 638aae2 commit 67470e1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/flutter/test/widgets/app_test.dart‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ void main() {
621621
builder: (BuildContext context) =>
622622
const Text('overlay content', textDirection: TextDirection.ltr),
623623
);
624-
addTearDown(entry.remove);
624+
addTearDown(
625+
() => entry
626+
..remove()
627+
..dispose(),
628+
);
625629
delegate.navigatorKey.currentState!.overlay!.insert(entry);
626630
await tester.pump();
627631

0 commit comments

Comments
 (0)