Skip to main content

SliverFillRemaining

Struct SliverFillRemaining 

Source
pub struct SliverFillRemaining {
    pub key: Option<KeyRef>,
    pub child: Option<WidgetRef>,
    pub has_scroll_body: bool,
    pub fill_overscroll: bool,
}
Expand description

A sliver that contains a single box child that fills the remaining space in the viewport.

To learn more about slivers, see CustomScrollView::slivers.

SliverFillRemaining will size its child to fill the viewport in the cross axis. The extent of the sliver and its child’s size in the main axis is computed conditionally, described in further detail below.

Typically this will be the last sliver in a viewport, since (by definition) there is never any room for anything beyond this sliver.

§Main Axis Extent

§When SliverFillRemaining has a scrollable child

The has_scroll_body flag indicates whether the sliver’s child has a scrollable body. This value is never null, and defaults to true. A common example of this use is a NestedScrollView. In this case, the sliver will size its child to fill the maximum available extent. SliverFillRemaining will not constrain the scrollable area, as it could potentially have an infinite depth. This is also true for use cases such as a ScrollView when ScrollView::shrink_wrap is true.

§When SliverFillRemaining does not have a scrollable child

When has_scroll_body is set to false, the child’s size is taken into account when considering the extent to which it should fill the space. The extent to which the preceding slivers have been scrolled is also taken into account in deciding how to layout this sliver.

SliverFillRemaining will size its child to fill the viewport in the main axis if that space is larger than the child’s extent, and the amount of space that has been scrolled beforehand has not exceeded the main axis extent of the viewport.

SliverFillRemaining will defer to the size of its child if the child’s size exceeds the remaining space in the viewport.

SliverFillRemaining will defer to the size of its child if the SliverConstraints::preceding_scroll_extent exceeded the length of the viewport’s main axis.

For ScrollPhysics that allow overscroll, such as BouncingScrollPhysics, setting the fill_overscroll flag to true allows the size of the child to stretch, filling the overscroll area. It does this regardless of the path chosen to provide the child’s size.

See also:

  • SliverFillViewport, which sizes its children based on the size of the viewport, regardless of what else is in the scroll view.
  • crate::SliverList, which shows a list of variable-sized children in a viewport.

Fields§

§key: Option<KeyRef>§child: Option<WidgetRef>

Box child widget that fills the remaining space in the viewport.

The main SliverFillRemaining documentation contains more details.

§has_scroll_body: bool

Indicates whether the child has a scrollable body, this value cannot be null.

Defaults to true such that the child will extend beyond the viewport and scroll, as seen in NestedScrollView.

Setting this value to false will allow the child to fill the remainder of the viewport and not extend further. However, if the SliverConstraints::preceding_scroll_extent and/or the child’s extent exceeds the size of the viewport, the sliver will defer to the child’s size rather than overriding it.

§fill_overscroll: bool

Indicates whether the child should stretch to fill the overscroll area created by certain scroll physics, such as iOS’ default scroll physics. This flag is only relevant when has_scroll_body is false.

Defaults to false, meaning that the default behavior is for the child to maintain its size and not extend into the overscroll area.

Implementations§

Source§

impl SliverFillRemaining

Source

pub fn new() -> SliverFillRemaining

Creates a sliver that fills the remaining space in the viewport.

Source

pub fn key(self, key: KeyRef) -> SliverFillRemaining

Dart SliverFillRemaining(key:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> SliverFillRemaining

Dart SliverFillRemaining(child:).

Source

pub fn has_scroll_body(self, has_scroll_body: bool) -> SliverFillRemaining

Dart SliverFillRemaining(hasScrollBody:).

Source

pub fn fill_overscroll(self, fill_overscroll: bool) -> SliverFillRemaining

Dart SliverFillRemaining(fillOverscroll:).

Trait Implementations§

Source§

impl Debug for SliverFillRemaining

Source§

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

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

impl Default for SliverFillRemaining

Source§

fn default() -> SliverFillRemaining

Returns the “default value” for a type. Read more
Source§

impl StatelessWidget for SliverFillRemaining

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.

Auto Trait Implementations§

§

impl !RefUnwindSafe for SliverFillRemaining

§

impl !Send for SliverFillRemaining

§

impl !Sync for SliverFillRemaining

§

impl !UnwindSafe for SliverFillRemaining

§

impl Forget for SliverFillRemaining

§

impl Freeze for SliverFillRemaining
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for SliverFillRemaining

§

impl Unpin for SliverFillRemaining
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for SliverFillRemaining
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: 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<W> IntoWidget<StatelessKind> for W
where W: StatelessWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
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>