pub struct WindowInsets {
pub view_padding: EdgeInsets,
pub view_insets: EdgeInsets,
pub corner_insets: CornerInsets,
}Expand description
The inset vocabulary LayoutCtx::window_insets/PaintCtx::window_insets
return — lifted because a widget that lays itself out around the status
bar, notch, or on-screen keyboard cannot otherwise name the value those
accessors hand it. A bar laying out around the iPadOS window control
names the corner value, CornerInsets.
The window’s inset state, mirroring Flutter’s ViewportMetrics
(media_query.dart).
Carries the two per-edge sets a shell transports; the third (the derived
safe-area padding) is computed on demand, never
stored:
view_padding— system-UI-occluded edges (status/navigation bars, display cutout). Never includes the IME.view_insets— fully-obscured area, in practice the on-screen keyboard (IME). The status bar is never part of this on either platform.
All values are logical px (see the module docs). Default is
the all-zero state (no occlusion). PartialEq lets a shell compare the
freshly-read platform insets against the last-pushed value and skip a no-op
set_insets.
Fields§
§view_padding: EdgeInsetsSystem-UI-occluded edges (status/navigation bars, cutout), in logical px.
view_insets: EdgeInsetsFully-obscured edges (the IME/keyboard), in logical px.
corner_insets: CornerInsetsWindow-control corners, in logical px; see CornerInsets.
Implementations§
Source§impl WindowInsets
impl WindowInsets
Sourcepub fn new(view_padding: EdgeInsets, view_insets: EdgeInsets) -> WindowInsets
pub fn new(view_padding: EdgeInsets, view_insets: EdgeInsets) -> WindowInsets
Construct from the two transported per-edge sets; corners are
CornerInsets::ZERO (see with_corner_insets).
Sourcepub fn with_corner_insets(self, corner_insets: CornerInsets) -> WindowInsets
pub fn with_corner_insets(self, corner_insets: CornerInsets) -> WindowInsets
These insets with the window-control corner_insets set. padding()
is unaffected.
Sourcepub fn padding(&self) -> EdgeInsets
pub fn padding(&self) -> EdgeInsets
The derived safe-area padding: max(0.0, view_padding - view_insets)
per edge (Flutter’s formula, media_query.dart:152-170).
This is what a SafeArea widget insets by — where the IME
(view_insets) overlaps a system-bar edge (view_padding), that edge’s
safe-area padding clamps to zero (the IME already handles keyboard
avoidance for that edge). Computed on demand; never transported.
Sourcepub fn consuming(
self,
left: bool,
top: bool,
right: bool,
bottom: bool,
) -> WindowInsets
pub fn consuming( self, left: bool, top: bool, right: bool, bottom: bool, ) -> WindowInsets
These insets with the safe-area padding on
each enabled edge marked as consumed — the value a widget that has
already padded by those edges hands to its subtree.
Flutter parity: MediaQuery.removePadding as applied by SafeArea. For
each enabled edge, view_padding.<edge> is reduced by
self.padding().<edge> (saturating at zero); view_insets is left
untouched. The invariants are:
consuming(..).padding().<edge> == 0.0on every enabled edge;view_insetsis unchanged, so the IME still reaches descendants for keyboard avoidance;- disabled edges are unchanged in both sets;
consuming(..).corner_insets == self.corner_insets— corners are never consumed;- the operation is idempotent — consuming an already-consumed edge is a
no-op, which is what makes nested
SafeAreas consume only once.
Trait Implementations§
Source§impl Clone for WindowInsets
impl Clone for WindowInsets
Source§fn clone(&self) -> WindowInsets
fn clone(&self) -> WindowInsets
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WindowInsets
Source§impl Debug for WindowInsets
impl Debug for WindowInsets
Source§impl Default for WindowInsets
impl Default for WindowInsets
Source§fn default() -> WindowInsets
fn default() -> WindowInsets
Source§impl PartialEq for WindowInsets
impl PartialEq for WindowInsets
impl StructuralPartialEq for WindowInsets
Auto Trait Implementations§
impl Freeze for WindowInsets
impl RefUnwindSafe for WindowInsets
impl Send for WindowInsets
impl Sync for WindowInsets
impl Unpin for WindowInsets
impl UnsafeUnpin for WindowInsets
impl UnwindSafe for WindowInsets
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<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.