Skip to main content

OverlayEntry

Struct OverlayEntry 

Source
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: WidgetBuilder

This 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

Source

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.

Source

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.

Source

pub fn set_opaque(self: Handle<Self>, app: &mut App, value: bool)

Sets opaque.

Source

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.

Source

pub fn set_maintain_state(self: Handle<Self>, app: &mut App, value: bool)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for OverlayEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ListenableObject for OverlayEntry

Source§

fn add_listener(self: Handle<Self>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<Self>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.

Auto Trait Implementations§

§

impl !RefUnwindSafe for OverlayEntry

§

impl !Send for OverlayEntry

§

impl !Sync for OverlayEntry

§

impl !UnwindSafe for OverlayEntry

§

impl Forget for OverlayEntry

§

impl Freeze for OverlayEntry
where *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> ValueNotifier<Option<Handle<OverlayEntryWidgetState>>>>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, PhantomData<fn() -> OverlayState>: Freeze, *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze,

§

impl Move for OverlayEntry

§

impl Unpin for OverlayEntry
where Rc<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Key>: Unpin,

§

impl UnsafeUnpin for OverlayEntry
where *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> ValueNotifier<Option<Handle<OverlayEntryWidgetState>>>>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, PhantomData<fn() -> OverlayState>: UnsafeUnpin, *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>