Repository navigation
Document that Positioned also works inside an Overlay - #190607
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for Positioned and PositionedDirectional to clarify that they can be descendants of an Overlay in addition to a Stack. The review feedback suggests refining this documentation to accurately state that the path to the ancestor performing the stack layout (such as Overlay's internal layout widget) must only contain StatelessWidgets or StatefulWidgets, as Overlay itself contains an internal RenderObjectWidget (_Theatre).
|
Good catch on the I fixed it slightly differently from the suggestion, to avoid describing a private widget in public docs. The
That statement holds: between the widget an entry builds and the overlay's stack layout there is only |
QuncCccccc
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
|
Thanks for the review! Applied both wordings, the subtree phrasing is more accurate anyway since the Positioned doesn't have to be the root of what the entry builds. Also added Overlay to the PositionedDirectional "See also" section, Positioned already had it. |
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM. Thanks again for your contribution:)
Positioned's doc comment says it must be a descendant of a Stack, but Overlay lays its entries out with the same stack layout, so a Positioned inside an OverlayEntry works with no Stack in between. Overlay's own docs already mention Positioned, so the two read inconsistently today. PositionedDirectional carries the same sentence and gets the same update.
Saying the path from Positioned to an enclosing Overlay contains only StatelessWidgets or StatefulWidgets was wrong: OverlayState builds _Theater, a RenderObjectWidget, so that path always crosses one. Keep the original Stack paragraph as it was and describe the Overlay case in terms of the widget built by an OverlayEntry, which is accurate -- between that widget and the overlay's stack layout there is only _OverlayEntryWidget, TickerMode, an InheritedWidget and a Builder.
Reword the Overlay paragraph on Positioned and PositionedDirectional to talk about the subtree an OverlayEntry builds rather than the widget it builds, and add Overlay to the PositionedDirectional 'See also' section.
d7ddc40 to
9227cc8
Compare
Positioned and PositionedDirectional still opened by saying they must be a descendant of a Stack, which contradicts the Overlay paragraph this PR adds. Describe the requirement in terms of the ancestor that performs the stack layout instead, and mention OverlayPortal next to OverlayEntry since it is the declarative API for putting a widget on an Overlay. AnimatedPositioned, AnimatedPositionedDirectional, PositionedTransition and RelativePositionedTransition all carried the same "Only works if it's the child of a Stack" line. Each builds a Positioned directly, with nothing but Stateless/Stateful widgets in between, so each works on an Overlay too. The Stack.alignment and non-positioned-child paragraphs stay scoped to Stack, because _RenderTheater does not behave the same way there: it always aligns partially positioned children to AlignmentDirectional.topStart and gives non-positioned children the overlay's size.
The restriction paragraph listed Overlay as one of the ancestors the path is measured to, but the path from a Positioned up to the Overlay widget crosses _Theater, which is a RenderObjectWidget, so the paragraph contradicted itself for that case. It now names the widget that performs the stack layout, with Stack as the example, and the Overlay case stays in its own paragraph anchored on the subtree an OverlayEntry or OverlayPortal.overlayChildBuilder builds. Also link Stack and Overlay in the top/right/bottom/left paragraphs, say "same stack layout algorithm" consistently, and add CompositedTransformFollower to PositionedDirectional's "See also".
|
Pushed. Summary of this round: the restriction paragraph no longer measures the path to the While checking the claims I ran a throwaway test locally rather than trusting the reading: The failing |
victorsanni
left a comment
There was a problem hiding this comment.
Are these changes applied to runtime errors as well? e.g debugTypicalAncestorWidgetClass
Replaces the three-paragraph explanation on Positioned and PositionedDirectional with the wording from review: name the boundary up front (the Stack, or the widget OverlayEntry.builder / OverlayPortal.overlayChildBuilder returns), anchor the stack layout algorithm to RenderStack, then spell out both boundaries so the Stack endpoint being a RenderObjectWidget and the Overlay root not being one are no longer left to inference. Drops the sentences restating how an Overlay aligns and sizes non-positioned entries in favour of a pointer to Overlay, so the Positioned docs do not bitrot if that behaviour changes. The four short notes on AnimatedPositioned, AnimatedPositionedDirectional, PositionedTransition and RelativePositionedTransition no longer describe the widget as the child of an Overlay, which overlay entries are not.
|
@victorsanni Pushed
Before writing the boundary paragraph I checked the three cases against the framework: Two things I can't do from my side:
|
victorsanni
left a comment
There was a problem hiding this comment.
Can you update the PR description with the latest state?
The breadcrumbs added last round sent readers to Overlay for how it aligns and sizes non-positioned entries, but Overlay did not document that. It now does, next to the Directionality paragraph, and lists Positioned in its "See also" the way Positioned already lists it. Also covers the third builder, OverlayPortal.overlayChildLayoutBuilder, and states the path restriction as "must not contain any RenderObjectWidgets" instead of listing the two widget kinds that are allowed. The framework walks up to the first RenderObjectElement, so anything that is not a RenderObjectWidget is fine, InheritedWidget included; verified by test before writing it. The alignment sentence now says an Overlay has no equivalent of Stack.alignment rather than dropping the subject entirely.
|
@victorsanni Pushed The one that needed real work was your question about whether The rest:
Same note as last time: I can't re-request a review from my account — REST returns 404 and GraphQL returns |
Two things the last round got wrong. The overlay paragraph said a non-positioned entry is given the size of the overlay and that the overlay never sizes itself to its entries. _RenderTheater.performLayout only takes constraints.biggest when !alwaysSizeToContent && constraints.biggest.isFinite; otherwise _findSizeDeterminingChild picks the topmost non-positioned entry with canSizeOverlay and the overlay takes that child's size, which the canSizeOverlay and alwaysSizeToContent docs in the same file already say. It also said such entries are aligned to AlignmentDirectional .topStart, but layoutChild gives them tight constraints and Offset.zero; _resolvedAlignment only reaches RenderStack.layoutPositionedChild, so it applies to positioned children that leave an axis unspecified. The path restriction said it must not contain any RenderObjectWidgets. That misses ParentDataWidgets: Stack > Expanded > Positioned throws Incorrect use of ParentDataWidget even though Expanded renders nothing. Verified with Expanded, Flexible and a nested Positioned. Also names the three builders consistently instead of saying "Both" after listing three, covers OverlayPortal in the overlay paragraph, and fixes the See also entry, since an OverlayEntry is not a widget and so cannot itself be wrapped.
|
@victorsanni Pushed The overlay paragraph was wrong twice. The path restriction missed The rest: the "Both" sentence now names Re-requesting a review still fails from my account (REST 404, GraphQL |
flutter/flutter@5e805bf...ee8b482 2026-10-31 [email protected] Roll Skia from 9bab765df357 to 607de4b035dc (1 revision) (flutter/flutter#195728) 2026-10-31 [email protected] Roll Skia from 284054bec98a to 9bab765df357 (2 revisions) (flutter/flutter#195726) 2026-10-31 [email protected] Roll Skia from 3a3f56f7ddd4 to 284054bec98a (1 revision) (flutter/flutter#195724) 2026-10-31 [email protected] Roll Skia from 466994d27b1e to 3a3f56f7ddd4 (1 revision) (flutter/flutter#195719) 2026-10-30 [email protected] Fix XcodeProjectInterpreter dependency cycle in flutter_tools (flutter/flutter#195694) 2026-10-30 [email protected] Document that Positioned also works inside an Overlay (flutter/flutter#190607) 2026-10-30 [email protected] Roll Skia from ce0b85b46db6 to 466994d27b1e (3 revisions) (flutter/flutter#195711) 2026-10-30 [email protected] Adds Vulkan sync validation test run (flutter/flutter#195596) 2026-10-30 [email protected] [Android] Let the raster thread use every core of a chip without little cores (flutter/flutter#195071) 2026-10-30 [email protected] Roll Skia from 121d04c01e2d to ce0b85b46db6 (6 revisions) (flutter/flutter#195699) 2026-10-30 [email protected] [web] Anchor platform view slots to top-left to fix RTL document layout (flutter/flutter#194601) 2026-10-30 [email protected] Update golden file testing docs (flutter/flutter#195449) 2026-10-30 [email protected] [tool] Migrate Cache.flutterRoot static state to instance configuration (flutter/flutter#190795) 2026-10-30 [email protected] Apply view metrics overrides below the framework (flutter/flutter#194311) 2026-10-30 [email protected] Roll Skia from c0c46ee9f938 to 121d04c01e2d (9 revisions) (flutter/flutter#195687) 2026-10-30 [email protected] Use uniforms in the Porter Duff blend shader instead of specialization constants (flutter/flutter#195458) 2026-10-30 [email protected] [flutter_tools] Inject dependencies into iOS, macOS, and Windows application packages (flutter/flutter#194047) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
`Positioned` works inside an `Overlay` as well as a `Stack`, but its documentation only described the `Stack` case. This updates the documentation across `Positioned`, `PositionedDirectional`, the animated variants and the transition variants. Fixes flutter#107903. The path restriction now covers both `RenderObjectWidget`s and other `ParentDataWidget`s, including `Expanded`, and identifies the boundary for each of the three overlay builders. `Overlay` documents the positioned-child alignment and normal non-positioned-child sizing, with links to `canSizeOverlay` and `alwaysSizeToContent` for the cases where a child determines the overlay size. Documentation only; no behavior or API changes. Validation from the review rounds is recorded in the inline replies and summary comments. The latest corrections are in `a9cecb891`. ## 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 documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. This PR is test-exempt because it only edits dartdoc text, with no behavioral or API changes. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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 [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 --------- Co-authored-by: Victor Sanni <[email protected]>
flutter/flutter#190607 merged on 2026-10-30, so it leads the list as contributions[0] and gets its own case study. Also bring the hard-coded copy in line with five merged PRs: the /open-source metadata and hero, the SEO paragraph, the JSON-LD description (it credited every PR to flutter/flutter), the tunnel tagline (still said three) and the OG subtitle. The resume was missing #192727 too; it now folds the four Flutter PRs into one entry and the PDFs are regenerated at one page.
Positionedworks inside anOverlayas well as aStack, but its documentation only described theStackcase. This updates the documentation acrossPositioned,PositionedDirectional, the animated variants and the transition variants.Fixes #107903.
The path restriction now covers both
RenderObjectWidgets and otherParentDataWidgets, includingExpanded, and identifies the boundary for each of the three overlay builders.Overlaydocuments the positioned-child alignment and normal non-positioned-child sizing, with links tocanSizeOverlayandalwaysSizeToContentfor the cases where a child determines the overlay size.Documentation only; no behavior or API changes.
Validation from the review rounds is recorded in the inline replies and summary comments. The latest corrections are in
a9cecb891.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.