-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Use case
RenderBox.localToGlobal uses getTransformTo which is called during the layout phase. Calling getTransformTo at build phase to build an overlay child causes a frame delay because changes are scheduled for the next build. This can lead to bugs like #167359 and #168545.
Proposal
The new OverlayPortal.overlayChildLayoutBuilder was added to solve this problem:
flutter/packages/flutter/lib/src/widgets/overlay.dart
Lines 1805 to 1826 in 052b903
| /// Creates an [OverlayPortal] that renders the widget `overlayChildBuilder` | |
| /// builds on the closest [Overlay] when [OverlayPortalController.show] is | |
| /// called. | |
| /// | |
| /// Developers can use `overlayChildBuilder` to configure the overlay child | |
| /// based on the the size and the location of [OverlayPortal.child] within the | |
| /// target [Overlay], as well as the size of the [Overlay] itself. This allows | |
| /// the overlay child to, for example, always follow [OverlayPortal.child] and | |
| /// at the same time resize itself base on how close it is to the edges of | |
| /// the [Overlay]. | |
| /// | |
| /// The `overlayChildBuilder` callback is called during layout. To ensure the | |
| /// paint transform of [OverlayPortal.child] in relation to the target | |
| /// [Overlay] is up-to-date by then, all [RenderObject]s between the | |
| /// [OverlayPortal] to the target [Overlay] must establish their paint | |
| /// transform during the layout phase, which most [RenderObject]s do. One | |
| /// exception is the [CompositedTransformFollower] widget, whose [RenderObject] | |
| /// only establishes the paint transform when composited. Putting a | |
| /// [CompositedTransformFollower] between the [OverlayPortal] and the [Overlay] | |
| /// may resulting in an incorrect child paint transform being provided to the | |
| /// `overlayChildBuilder` and will cause an assertion in debug mode. | |
| OverlayPortal.overlayChildLayoutBuilder({ |
Migrate usage of OverlayPortal with RenderBox.localToGlobal to OverlayPortal.overlayChildLayoutBuilder, for example, in RawMenuAnchor.
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team