pub struct OverlayEntry {
pub builder: WidgetBuilder,
/* private fields */
}Expand description
A place in an Overlay that can contain a widget.
Overlay entries are inserted into an Overlay using the OverlayState::insert or
OverlayState::insert_all functions. To find the closest enclosing overlay for a given
BuildContext, use the Overlay::of function.
An overlay entry can be in at most one overlay at a time. To remove an entry from its
overlay, call the remove function on the overlay entry.
Because an Overlay uses a stack layout, overlay entries can use Positioned to
position themselves within the overlay.
By default, if there is an entirely opaque entry over this one, then this
one will not be included in the widget tree (in particular, stateful widgets within the
overlay entry will not be instantiated). To ensure that your overlay entry is still built
even if it is not visible, set maintain_state to true. This is
more expensive, so should be done with care.
Handle<OverlayEntry> is a Listenable that notifies
when the widget built by builder is mounted or unmounted, whose exact
state can be queried by mounted. After the owner of the OverlayEntry calls
remove and then dispose, the widget may not be
immediately removed from the widget tree. As a result listeners of the OverlayEntry can
get notified for one last time after the dispose call, when the widget is eventually
unmounted.
See also:
Overlay, a stack of entries that can be managed independently.OverlayState, the current state of an Overlay.
Fields§
§builder: WidgetBuilderThis entry will include the widget built by this builder in the overlay at the entry’s position.
To cause this builder to be called again, call mark_needs_build on this overlay
entry.
Implementations§
Source§impl OverlayEntry
impl OverlayEntry
Sourcepub fn new(
app: &mut App,
builder: WidgetBuilder,
opaque: bool,
maintain_state: bool,
can_size_overlay: bool,
) -> Ref<OverlayEntry>
pub fn new( app: &mut App, builder: WidgetBuilder, opaque: bool, maintain_state: bool, can_size_overlay: bool, ) -> Ref<OverlayEntry>
Creates an overlay entry.
To insert the entry into an Overlay, first find the overlay using Overlay::of
and then call OverlayState::insert. To remove the entry, call
remove on the overlay entry itself.
Dart’s defaults: opaque false, maintain_state false, can_size_overlay false.
Sourcepub fn opaque(self: Handle<Self>, app: &App) -> bool
pub fn opaque(self: Handle<Self>, app: &App) -> bool
Whether this entry occludes the entire overlay.
If an entry claims to be opaque, then, for efficiency, the overlay will skip building
entries below that entry unless they have maintain_state set.
Sourcepub fn maintain_state(self: Handle<Self>, app: &App) -> bool
pub fn maintain_state(self: Handle<Self>, app: &App) -> bool
Whether this entry must be included in the tree even if there is a fully
opaque entry above it.
By default, if there is an entirely opaque entry over this one, then this one will not be included in the widget tree (in particular, stateful widgets within the overlay entry will not be instantiated). To ensure that your overlay entry is still built even if it is not visible, set this to true. This is more expensive, so should be done with care.
This is used by the Navigator and Route objects to ensure that routes are kept
around even when in the background.
Sourcepub fn set_maintain_state(self: Handle<Self>, app: &mut App, value: bool)
pub fn set_maintain_state(self: Handle<Self>, app: &mut App, value: bool)
Sets maintain_state.
Sourcepub fn can_size_overlay(self: Handle<Self>, app: &App) -> bool
pub fn can_size_overlay(self: Handle<Self>, app: &App) -> bool
Whether the content of this OverlayEntry can be used to size the Overlay.
In most situations the overlay sizes itself based on its incoming constraints to be as
large as possible. However, if that would result in an infinite size, it has to rely on
one of its children to size itself. In this situation, the overlay will consult the
topmost non-positioned overlay entry that has this property set to true, lay it out with
the incoming BoxConstraints of the overlay, and force all other non-positioned
overlay entries to have the same size.
Overlay entries that set this to true must be able to handle unconstrained
BoxConstraints.
Sourcepub fn mounted(self: Handle<Self>, app: &App) -> bool
pub fn mounted(self: Handle<Self>, app: &App) -> bool
Whether the OverlayEntry is currently mounted in the widget tree.
The OverlayEntry notifies its listeners when this value changes.
Sourcepub fn remove(self: Handle<Self>, app: &mut App)
pub fn remove(self: Handle<Self>, app: &mut App)
Remove this entry from the overlay.
This should only be called once.
This method removes this overlay entry from the overlay immediately. The UI will be updated in the same frame if this method is called before the overlay rebuild in this frame; otherwise, the UI will be updated in the next frame.
Sourcepub fn mark_needs_build(self: Handle<Self>, app: &mut App)
pub fn mark_needs_build(self: Handle<Self>, app: &mut App)
Cause this entry to rebuild during the next pipeline flush.
You need to call this function if the output of builder has changed.
Sourcepub fn dispose(self: Handle<Self>, app: &mut App)
pub fn dispose(self: Handle<Self>, app: &mut App)
Discards any resources used by this OverlayEntry.
The remove method must be called before this method if the
OverlayEntry is inserted into an Overlay.
After this is called, the object is not in a usable state and should be discarded.
However, the listeners registered may not be immediately released until the widget built
using this OverlayEntry is unmounted from the widget tree.
This method should only be called by the object’s owner.