Skip to main content

SliverWidget

Trait SliverWidget 

Source
pub trait SliverWidget: Widget {
    // Required method
    fn layout_sliver(
        &mut self,
        ctx: &mut LayoutCtx<'_>,
        sc: &SliverConstraints,
    ) -> SliverGeometry;
}
Expand description

The sliver protocol a scrolling viewport lays its children out with — a widget implements SliverWidget and overrides Widget::as_sliver to answer SliverConstraints with a SliverGeometry; a viewport lays such a child out through ChildPod::layout_sliver_child. Lifted so an app’s own sliver needs no direct frust-core dependency. A widget that can be laid out as a sliver inside a scrolling viewport — Flutter’s RenderSliver’s layout half (performLayout against SliverConstraints, producing geometry).

A sliver is still a Widget: it paints, handles events and contributes semantics like any other, in a local space whose size is (cross_axis_extent, paint_extent) in axis terms (what ChildPod::layout_sliver_child records as the pod’s size). A type implementing this trait opts in by overriding Widget::as_sliver to return Some(self); its box Widget::layout still answers when it is laid out outside a viewport.

The layout-skip contract on Widget::layout applies unchanged: the result of layout_sliver must be a function of sc, the context’s global inputs, and state that only changes through a channel that dirties the pod.

Required Methods§

Source

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Lay the sliver out under sc and report its geometry, which must satisfy SliverGeometry::debug_assert_valid against sc.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SliverWidget for GestureDetectorWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Pass-through, like Widget::layout: the child sits at the origin and receives sc unchanged, under the child pod’s layout skip. The box layout does nothing beyond the child layout and origin, so the sliver layout preserves it exactly; every gesture and event path is untouched.

Source§

impl SliverWidget for HeroWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Pass-through, like Widget::layout: the child sits at the origin and receives sc unchanged, under the child pod’s layout skip.

Source§

impl SliverWidget for ShieldWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Pass-through, like Widget::layout: the child sits at the origin and receives sc unchanged, under the child pod’s layout skip.

Source§

impl SliverWidget for SliverBoxWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverFillRemainingWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverFixedExtentListWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverGridWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverListWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverPaddingWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Source§

impl SliverWidget for SliverPersistentHeaderWidget

Source§

fn layout_sliver( &mut self, ctx: &mut LayoutCtx<'_>, sc: &SliverConstraints, ) -> SliverGeometry

Implementors§