OverlayPortal.overlayChildLayoutBuilder constructor

OverlayPortal.overlayChildLayoutBuilder({
  1. Key? key,
  2. required OverlayPortalController controller,
  3. required OverlayChildLayoutBuilder overlayChildBuilder,
  4. required Widget? child,
})

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 RenderObjects between the OverlayPortal to the target Overlay must establish their paint transform during the layout phase, which most RenderObjects 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.

Implementation

OverlayPortal.overlayChildLayoutBuilder({
  Key? key,
  required OverlayPortalController controller,
  required OverlayChildLayoutBuilder overlayChildBuilder,
  required Widget? child,
}) : this(
       key: key,
       controller: controller,
       overlayChildBuilder: (_) => _OverlayChildLayoutBuilder(builder: overlayChildBuilder),
       child: child,
     );