Skip to content

Add OverlayPortal.overlayChildLayoutBuilder sample#188930

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
loic-sharma:overlay_portal_child_layout_builder_sample
Jul 22, 2026
Merged

Add OverlayPortal.overlayChildLayoutBuilder sample#188930
auto-submit[bot] merged 4 commits into
flutter:masterfrom
loic-sharma:overlay_portal_child_layout_builder_sample

Conversation

@loic-sharma

@loic-sharma loic-sharma commented Jul 2, 2026

Copy link
Copy Markdown
Member

This mirrors the existing OverlayPortal example:

https://github.com/flutter/flutter/blob/master/examples/api/lib/widgets/overlay/overlay_portal.0.dart#L1-L58

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • 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.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 2, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Jul 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new code sample demonstrating OverlayPortal.overlayChildLayoutBuilder along with its corresponding widget tests. Feedback on the changes includes fixing a syntax error where EdgeInsets is missing from the padding property, and refactoring the tests to use more specific ancestor finders instead of generic type finders to prevent fragility.

Comment thread examples/api/lib/widgets/overlay/overlay_portal.1.dart Outdated
Comment thread examples/api/test/widgets/overlay/overlay_portal.1_test.dart Outdated
@loic-sharma
loic-sharma force-pushed the overlay_portal_child_layout_builder_sample branch from cbe006c to 9804cf3 Compare July 2, 2026 22:01
LongCatIsLooong
LongCatIsLooong previously approved these changes Jul 3, 2026

@LongCatIsLooong LongCatIsLooong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm with nits.

final OverlayPortalController _controller = OverlayPortalController();

Widget _buildOverlay(BuildContext context, OverlayChildLayoutInfo info) {
final Offset childOffset = MatrixUtils.transformPoint(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This offset can be NaN if the transform is a singular matrix. I think the best practice would be checking for NaN / check the determinant of the matrix (although in this example the transform is guaranteed to be a rigid motion, so maybe as a comment?)

@loic-sharma loic-sharma Jul 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a comment! Please feel free to leave feedback on the comment, my matrix math is veeeery rusty 😂

Widget _buildOverlay(BuildContext context, OverlayChildLayoutInfo info) {
final Offset childOffset = MatrixUtils.transformPoint(
info.childPaintTransform,
Offset.zero,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably better to transform the whole child rect sine childSize is reported in the child's own coordinates.

final Rect childRectInOverlay = MatrixUtils.transformRect(transform, Offset.zero & childSize);

The easiest way to implement follow is probably Transform but I think if there's scaling in the transform then RenderBox hit-testing culling might become a problem.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah thanks, good catch! I updated this to transform the whole child rect, but stuck to Positioned instead of Transform 👍

Comment thread examples/api/lib/widgets/overlay/overlay_portal.1.dart Outdated
LongCatIsLooong
LongCatIsLooong previously approved these changes Jul 5, 2026
Comment thread examples/api/lib/widgets/overlay/overlay_portal.1.dart Outdated
@loic-sharma
loic-sharma marked this pull request as draft July 14, 2026 23:22
@loic-sharma
loic-sharma marked this pull request as ready for review July 14, 2026 23:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new DartPad code sample and corresponding tests for OverlayPortal.overlayChildLayoutBuilder. A critical syntax error was identified in the code sample where the EdgeInsets class name was omitted from the padding property.

Comment thread examples/api/lib/widgets/overlay/overlay_portal.1.dart
@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 15, 2026
@auto-submit

auto-submit Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/188930, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Piinks
Piinks force-pushed the overlay_portal_child_layout_builder_sample branch from 60896c8 to 00b2101 Compare July 21, 2026 22:25
@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 21, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 22, 2026
Merged via the queue into flutter:master with commit 3f02ab8 Jul 22, 2026
20 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 22, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 22, 2026
flutter/flutter@1ac2e82...2a2a79d

2026-07-22 [email protected] Clear cached directional focus history on a non-directional focus request  (flutter/flutter#187957)
2026-07-22 [email protected] ci: Include root pubspec.yaml in pub cache key (flutter/flutter#189826)
2026-07-22 [email protected] Remove codecov badge from README (flutter/flutter#189728)
2026-07-22 [email protected] Clean android engine/embedding tests (flutter/flutter#189276)
2026-07-22 [email protected] Add barrierBuilder support to showDialog and showGeneralDialog (flutter/flutter#187992)
2026-07-22 [email protected] Fix Mockito dynamic agent loading warnings in Robolectric tests (flutter/flutter#189804)
2026-07-22 [email protected] [iOS] Remove dead RasterThreadMerger plumbing from platform views (flutter/flutter#189753)
2026-07-22 [email protected] Add OverlayPortal.overlayChildLayoutBuilder sample (flutter/flutter#188930)
2026-07-22 [email protected] Automate recurring tasks via workflows - localizations (flutter/flutter#189750)
2026-07-21 [email protected] [iOS] Remove dead parameters and no-op overrides (flutter/flutter#189754)
2026-07-21 [email protected] [iOS] Inject DisplayLinkManager into FlutterViewController (flutter/flutter#189764)
2026-07-21 [email protected] Support custom BoxBorder animation in BoxDecoration (flutter/flutter#186348)
2026-07-21 [email protected] Rename CpuArch.x86_64 to CpuArch.x64 (flutter/flutter#189478)
2026-07-21 [email protected] Roll Skia from 569534e9fa59 to 5e183e5aeac5 (3 revisions) (flutter/flutter#189795)
2026-07-21 [email protected] Roll Dart SDK from 3b2f5ad7718d to 1e65011ee004 (4 revisions) (flutter/flutter#189791)
2026-07-21 [email protected] Run delete-bot-branches.yaml on `pull_request_target` instead of `pull_request` so that we can access secrets. (flutter/flutter#189793)
2026-07-21 [email protected] Batch release directory correction (flutter/flutter#189738)
2026-07-21 [email protected] [flutter_test][Test cross imports] Move TestWidgetsApp to flutter_test (flutter/flutter#189435)
2026-07-21 [email protected] Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589) (flutter/flutter#189667)
2026-07-21 [email protected] Roll Packages from 611899b to 8260a1e (10 revisions) (flutter/flutter#189782)
2026-07-21 [email protected] [iOS] Inject DisplayLinkManager into FlutterMetalLayer (flutter/flutter#189752)
2026-07-21 [email protected] Derive the SkImage size used by ImageEncodingImpeller::ConvertDlImageToSkImage from the size of the underlying texture, not the size of the DlImage (flutter/flutter#189739)

If this roll has caused a breakage, revert this CL and stop the roller
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants