这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@chunhtai
Copy link
Contributor

for #174239

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 22, 2025
@gemini-code-assist
Copy link
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@LongCatIsLooong
Copy link
Contributor

The google testing failures seem legit too. Looks like you may not be able to call Overlay.of in initState if you want to establish a dependency?

@chunhtai
Copy link
Contributor Author

The google testing failures seem legit too. Looks like you may not be able to call Overlay.of in initState if you want to establish a dependency?

yeah I have to migrate them, you are not suppose to look up ancestor chain during initState anyway. I will see how bad it is and may do a migration guide

@LongCatIsLooong
Copy link
Contributor

LongCatIsLooong commented Aug 25, 2025

The google testing failures seem legit too. Looks like you may not be able to call Overlay.of in initState if you want to establish a dependency?

yeah I have to migrate them, you are not suppose to look up ancestor chain during initState anyway. I will see how bad it is and may do a migration guide

For OverlayEntry related use cases the new dependency established via the Overlay.of API after this change isn't really necessary tho (since those APIs are mostly imperative). According to the initState doc it seems it's OK to look up ancestors (however you're not supposed to use inherited widgets yet, not sure why these two are different).

However Overlay.of establishing dependency does make it more consistent with other .of APIs, I wish we had given the no dependency version a different name so we could keep both.

@chunhtai
Copy link
Contributor Author

For OverlayEntry related use cases the new dependency established via the Overlay.of API after this change isn't really necessary tho (since those APIs are mostly imperative). According to the initState doc it seems it's OK to look up ancestors (however you're not supposed to use inherited widgets yet, not sure why these two are different).

However Overlay.of establishing dependency does make it more consistent with other .of APIs, I wish we had given the no dependency version a different name so we could keep both.

Yes this is unfortunate, but I can't think of a good way to mitigate this. I still plan to make the hard switch, Do you have any other suggestion?

@LongCatIsLooong
Copy link
Contributor

For OverlayEntry related use cases the new dependency established via the Overlay.of API after this change isn't really necessary tho (since those APIs are mostly imperative). According to the initState doc it seems it's OK to look up ancestors (however you're not supposed to use inherited widgets yet, not sure why these two are different).
However Overlay.of establishing dependency does make it more consistent with other .of APIs, I wish we had given the no dependency version a different name so we could keep both.

Yes this is unfortunate, but I can't think of a good way to mitigate this. I still plan to make the hard switch, Do you have any other suggestion?

Maybe leave Overlay.of as-is and add the new static method to a class that's more closely associated with OverlayPortal (which is the only known use case of the new API it seems)?

@chunhtai
Copy link
Contributor Author

I am concern about having a different static method that does what .of usually do, but the actual .of does something else.

Do you think allow looking up ancestor in initstate is a good idea in the first place? Last time I talked with Michael, there is really no good reason that we use findAncestorState any more since we have inherited widget, that means all the .of method should be implement with inherited widget. WDYT?

@LongCatIsLooong
Copy link
Contributor

LongCatIsLooong commented Aug 25, 2025

Do you think allow looking up ancestor in initstate is a good idea in the first place?

I don't think it's the best place to call OverlayEntry APIs. I know there are apps currently doing that, iirc one of them want the OverlayEntry to have the same lifespan as the main widget.

Last time I talked with Michael, there is really no good reason that we use findAncestorState any more since we have inherited widget, that means all the .of method should be implement with inherited widget. WDYT?

Are you deprecating findAncestorState? I think findAncestorState probably has its own use cases: if you don't use Overlay.of there's no additional overhead whatsoever, as compared to inherited widgets with which you'll have to add entries to _dependencies and _inheritedElements. With _inheritedElements now being a persistent hashmap this should be negligible, especially for Overlays since you typically don't have a lot of Overlays in a widget tree so it definitely makes sense to switch over to inherited widgets. But if you know an ancestor widget is only one parent away from you (which is kinda common if you're writing you own widget) I think findAncestorState is the more common choice since you don't want to go out of the way to introduce a new InheritedWidget type (ParentDataWidget is one that I can think of).

@chunhtai
Copy link
Contributor Author

I know there are apps currently doing that, iirc one of them want the OverlayEntry to have the same lifespan as the main widget.

They can and probably should initialize it in didChangeDependencies, and dispose it in dispose. We do this all the time.

Are you deprecating findAncestorState?

not deprecating entirely, I am pretty sure there will be use case that only findAncestorState can do. e.g. you need to own the ancestor widget in order to migrate findAncestorState to inheritedWidget.

instead, avoid using findAncestorState to implement .of method

@chunhtai chunhtai changed the title Overlay.of also create dependencies Implement Overlay.of with inherited widget Aug 26, 2025
LookupBoundary.getElementForInheritedWidgetOfExactType<_RenderTheaterMarker>(context);
if (rootOverlay) {
InheritedElement? walker = element;
while (walker != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like there's already a _rootRenderTheaterMarkerOf method for looking up the root Overlay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with 2 nits.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 2, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 2, 2025
Roll Flutter from da5523afc3c1 to 6b18740d5a23 (49 revisions)

flutter/flutter@da5523a...6b18740

2025-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from 11f6cd99f6b3 to 72cda0f3dc42 (2 revisions) (flutter/flutter#174697)
2025-08-29 sokolovskyi.konstantin@gmail.com Fix empty adaptive text selection toolbars building. (flutter/flutter#174656)
2025-08-29 jhy03261997@gmail.com [flutter_test] update the _isImportantForAccessibility method in SemanticsController to include tooltip (flutter/flutter#174476)
2025-08-29 engine-flutter-autoroll@skia.org Roll Skia from 89794f0b5384 to 43e79dc80ca8 (1 revision) (flutter/flutter#174678)
2025-08-29 engine-flutter-autoroll@skia.org Roll Skia from f3c8b4c677f5 to 89794f0b5384 (6 revisions) (flutter/flutter#174675)
2025-08-29 47866232+chunhtai@users.noreply.github.com Implement Overlay.of with inherited widget (flutter/flutter#174315)
2025-08-29 jacksongardner@google.com [impeller] Support partitioned host buffer (flutter/flutter#174463)
2025-08-29 47866232+chunhtai@users.noreply.github.com Adds semantics for disabled buttons in date picker (flutter/flutter#174064)
2025-08-29 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from bHYRvLv2Dg56RWZF2... to 00VSr-5B7hq0G2eZx... (flutter/flutter#174667)
2025-08-29 robert.ancell@canonical.com Check GTK calls are done on the same thread. (#174488) (flutter/flutter#174624)
2025-08-29 bkonyi@google.com [ Tool ] Only listen for DebugConnectionInfo if the service protocol is supported (flutter/flutter#174664)
2025-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from 89023922f96d to 11f6cd99f6b3 (9 revisions) (flutter/flutter#174669)
2025-08-28 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[web] Refactor renderers to use the same frontend code (#174588)" (flutter/flutter#174672)
2025-08-28 jhy03261997@gmail.com [a11y] [test] containsSemantics  can ignore SemanticsValidationResult (flutter/flutter#174608)
2025-08-28 sokolovskyi.konstantin@gmail.com Fix some issues in engine-tool README. (flutter/flutter#174512)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro new_gallery__transition_perf to be flaky (flutter/flutter#174106)
2025-08-28 ahmedsameha1@gmail.com Make sure that an AlertDialog doesn't crash in 0x0 environment (flutter/flutter#174091)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro hello_world_impeller to be flaky (flutter/flutter#173699)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro drive_perf_debug_warning to be flaky (flutter/flutter#174112)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_android_emu android_display_cutout to be flaky (flutter/flutter#174501)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro service_extensions_test to be flaky (flutter/flutter#174114)
2025-08-28 fluttergithubbot@gmail.com Marks Windows plugin_test to be flaky (flutter/flutter#174117)
2025-08-28 fluttergithubbot@gmail.com Marks Windows_mokey basic_material_app_win__compile to be flaky (flutter/flutter#173702)
2025-08-28 fluttergithubbot@gmail.com Marks Mac_mokey microbenchmarks to be flaky (flutter/flutter#174102)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_mokey complex_layout__start_up to be flaky (flutter/flutter#173692)
2025-08-28 fluttergithubbot@gmail.com Marks Linux build_android_host_app_with_module_aar to be flaky (flutter/flutter#172631)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro new_gallery_opengles_impeller__transition_perf to be flaky (flutter/flutter#173338)
2025-08-28 fluttergithubbot@gmail.com Marks Linux_pixel_7pro platform_views_scroll_perf_impeller__timeline_summary to be flaky (flutter/flutter#172211)
2025-08-28 jason-simmons@users.noreply.github.com Remove the option to disable the merged platform/UI thread on Android and iOS (flutter/flutter#174408)
2025-08-28 mdebbar@google.com Don't fail when hot restarting `web-server` and there are no connected clients (flutter/flutter#174600)
2025-08-28 engine-flutter-autoroll@skia.org Roll Skia from 7c2fe2629d4a to f3c8b4c677f5 (7 revisions) (flutter/flutter#174654)
2025-08-28 mdebbar@google.com [WebParagraph] More plumbing towards making it usable in Flutter apps (flutter/flutter#174587)
2025-08-28 engine-flutter-autoroll@skia.org Roll Packages from 86fbeec to 141d8e3 (6 revisions) (flutter/flutter#174645)
2025-08-28 1961493+harryterkelsen@users.noreply.github.com [web] Refactor renderers to use the same frontend code (flutter/flutter#174588)
2025-08-28 engine-flutter-autoroll@skia.org Roll Skia from eb000b138a9d to 7c2fe2629d4a (3 revisions) (flutter/flutter#174637)
2025-08-28 bkonyi@google.com [ Tool ] Roll package:dwds 25.0.4 (flutter/flutter#174601)
2025-08-28 engine-flutter-autoroll@skia.org Roll Skia from 9b1642f2cfea to eb000b138a9d (2 revisions) (flutter/flutter#174627)
2025-08-28 engine-flutter-autoroll@skia.org Roll Skia from 430d60054d66 to 9b1642f2cfea (7 revisions) (flutter/flutter#174625)
2025-08-28 30870216+gaaclarke@users.noreply.github.com Refactored Canvas to disallow null inline contexts. (flutter/flutter#174530)
2025-08-28 flar@google.com Revert "Check GTK calls are done on the same thread." (flutter/flutter#174604)
2025-08-27 engine-flutter-autoroll@skia.org Roll Skia from 2a12b57fbbf0 to 430d60054d66 (3 revisions) (flutter/flutter#174590)
2025-08-27 ttankkeo112@gmail.com Retry "Implements the Android native stretch effect as a fragment shader (Impeller-only)." (flutter/flutter#173885)
2025-08-27 matanlurey@users.noreply.github.com Use raw `--removal-label "cp: ..."` when removing labels for unmerged PRs (flutter/flutter#174596)
2025-08-27 jakemac@google.com Flutter driver deserialization (flutter/flutter#172927)
2025-08-27 robert.ancell@canonical.com Check GTK calls are done on the same thread. (flutter/flutter#174488)
2025-08-27 matanlurey@users.noreply.github.com Fix broken reference to `PULL_REQUEST_CP_TEMPLATE.md` after refactor (flutter/flutter#174595)
...
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

for flutter#174239

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[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
[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
korca0220 pushed a commit to korca0220/flutter that referenced this pull request Sep 22, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

for flutter#174239

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[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
[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
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

for flutter#174239

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[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
[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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants