pub struct Overlay {
pub key: Option<KeyRef>,
pub initial_entries: Vec<Ref<OverlayEntry>>,
pub clip_behavior: Clip,
pub always_size_to_content: bool,
}Expand description
A stack of entries that can be managed independently.
Overlays let independent child widgets “float” visual elements on top of other widgets by
inserting them into the overlay’s stack. The overlay lets each of these widgets manage their
participation in the overlay using OverlayEntry objects.
Although you can create an Overlay directly, it’s most common to use the overlay created
by the Navigator. The navigator uses its overlay to manage the visual appearance of its
routes.
The Overlay widget uses a custom stack implementation, which is very similar to the
Stack widget. The main use case of Overlay is related to navigation and being able to
insert widgets on top of the pages in an app. For layout purposes unrelated to navigation,
consider using Stack instead.
An Overlay widget requires a Directionality widget to be in scope, so that it can
resolve direction-sensitive coordinates of any Positioned::directional children.
See also:
OverlayEntry, the class that is used for describing the overlay entries.OverlayState, which is used to insert the entries into the overlay.
Fields§
§key: Option<KeyRef>See Widget::key.
initial_entries: Vec<Ref<OverlayEntry>>The entries to include in the overlay initially.
These entries are only used when the OverlayState is initialized. If you are
providing a new Overlay description for an overlay that’s already in the tree, then
the new entries are ignored.
To add entries to an Overlay that is already in the tree, use Overlay::of to
obtain the OverlayState, and then use OverlayState::insert or
OverlayState::insert_all.
To remove an entry from an Overlay, use OverlayEntry::remove.
clip_behavior: ClipHow to clip the entries that overflow the overlay.
Defaults to Clip::HardEdge.
always_size_to_content: boolDetermines that the overlay should always size itself to content.
Normally overlay will only size itself to content if the incoming constraints are
infinite and there is an OverlayEntry that can size the overlay. Setting this to
true will force this behavior even for finite (but possibly loose) constraints.
Setting this to true requires an OverlayEntry that can size the overlay based on
itself (OverlayEntry::can_size_overlay set to true). If not provided the overlay
panics.
Implementations§
Source§impl Overlay
impl Overlay
Sourcepub fn new() -> Overlay
pub fn new() -> Overlay
Creates an overlay; Dart’s named arguments are the setters.
The initial entries will be inserted into the overlay when its associated
OverlayState is initialized.
Sourcepub fn initial_entries(
self,
entries: impl IntoIterator<Item = Ref<OverlayEntry>>,
) -> Overlay
pub fn initial_entries( self, entries: impl IntoIterator<Item = Ref<OverlayEntry>>, ) -> Overlay
Dart Overlay(initialEntries:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> Overlay
pub fn clip_behavior(self, clip_behavior: Clip) -> Overlay
Dart Overlay(clipBehavior:).
Sourcepub fn always_size_to_content(self, always_size_to_content: bool) -> Overlay
pub fn always_size_to_content(self, always_size_to_content: bool) -> Overlay
Dart Overlay(alwaysSizeToContent:).
Sourcepub fn wrap<K>(child: impl IntoWidget<K>) -> WrappingOverlay
pub fn wrap<K>(child: impl IntoWidget<K>) -> WrappingOverlay
Wrap the provided child in an Overlay to allow other visual elements (packed in
OverlayEntrys) to float on top of the child.
This is a convenience method over the regular Overlay constructor: it creates an
Overlay and puts the provided child in an OverlayEntry at the bottom of that
newly created Overlay.
Sourcepub fn of(
app: &mut App,
context: BuildContext,
root_overlay: bool,
) -> Handle<OverlayState>
pub fn of( app: &mut App, context: BuildContext, root_overlay: bool, ) -> Handle<OverlayState>
The OverlayState from the closest instance of Overlay that encloses the given
context, and panics if one is not found.
If root_overlay is set to true, the state from the furthest instance of this class is
given instead. Useful for installing overlay entries above all subsequent instances of
Overlay.
See also:
Overlay::maybe_offor a similar function that returnsNoneif anOverlayis not found.
Sourcepub fn maybe_of(
app: &mut App,
context: BuildContext,
root_overlay: bool,
) -> Option<Handle<OverlayState>>
pub fn maybe_of( app: &mut App, context: BuildContext, root_overlay: bool, ) -> Option<Handle<OverlayState>>
The OverlayState from the closest instance of Overlay that encloses the given
context, if any.
If root_overlay is set to true, the state from the furthest instance of this class is
given instead.
See also:
Overlay::offor a similar function that panics if anOverlayis not found.
Trait Implementations§
Source§impl StatefulWidget for Overlay
impl StatefulWidget for Overlay
Source§type State = OverlayState
type State = OverlayState
Source§fn create_state(&self) -> OverlayState
fn create_state(&self) -> OverlayState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for Overlay
impl !Send for Overlay
impl !Sync for Overlay
impl !UnwindSafe for Overlay
impl Forget for Overlay
impl Freeze for Overlaywhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Retained<Handle<OverlayEntry>>>: Freeze,
impl Move for Overlay
impl Unpin for Overlay
impl UnsafeUnpin for Overlaywhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Retained<Handle<OverlayEntry>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.