SliverFillRemaining class
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 hasScrollBody 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.shrinkWrap is true.
When SliverFillRemaining does not have a scrollable child
When hasScrollBody 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.
To create a local project with this code sample, run:
flutter create --sample=widgets.SliverFillRemaining.1 mysample
SliverFillRemaining will defer to the size of its child if the child's size exceeds the remaining space in the viewport.
To create a local project with this code sample, run:
flutter create --sample=widgets.SliverFillRemaining.2 mysample
SliverFillRemaining will defer to the size of its child if the SliverConstraints.precedingScrollExtent exceeded the length of the viewport's main axis.
To create a local project with this code sample, run:
flutter create --sample=widgets.SliverFillRemaining.3 mysample
For ScrollPhysics that allow overscroll, such as BouncingScrollPhysics, setting the fillOverscroll 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.
This sample only shows the overscroll behavior on devices that support overscroll.
To create a local project with this code sample, run:
flutter create --sample=widgets.SliverFillRemaining.4 mysample
See also:
- SliverFillViewport, which sizes its children based on the size of the viewport, regardless of what else is in the scroll view.
- SliverList, which shows a list of variable-sized children in a viewport.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- SliverFillRemaining
Constructors
- SliverFillRemaining({Key? key, Widget? child, bool hasScrollBody = true, bool fillOverscroll = false})
-
Creates a sliver that fills the remaining space in the viewport.
const
Properties
- child → Widget?
-
Box child widget that fills the remaining space in the viewport.
final
- fillOverscroll → 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 hasScrollBody is false.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasScrollBody → bool
-
Indicates whether the child has a scrollable body, this value cannot be
null.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited