SliverFillRemainingModifier class
A sliver that contains a single box child that fills the remaining space in the viewport.
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.
{@tool dartpad}
In this sample the SliverFillRemaining sizes its child
to fill the
remaining extent of the viewport in both axes. The icon is centered in the
sliver, and would be in any computed extent for the sliver.
** See code in examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.0.dart ** {@end-tool}
SliverFillRemaining will defer to the size of its child
if the
child's size exceeds the remaining space in the viewport.
{@tool dartpad}
In this sample the SliverFillRemaining defers to the size of its child
because the child's extent exceeds that of the remaining extent of the
viewport's main axis.
** See code in examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.1.dart ** {@end-tool}
SliverFillRemaining will defer to the size of its child
if the
SliverConstraints.precedingScrollExtent exceeded the length of the viewport's main axis.
{@tool dartpad}
In this sample the SliverFillRemaining defers to the size of its child
because the SliverConstraints.precedingScrollExtent has gone
beyond that of the viewport's main axis.
** See code in examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.2.dart ** {@end-tool}
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.
{@tool dartpad} In this sample the SliverFillRemaining's child stretches to fill the overscroll area when fillOverscroll is true. This sample also features a button that is pinned to the bottom of the sliver, regardless of size or overscroll behavior. Try switching fillOverscroll to see the difference.
This sample only shows the overscroll behavior on devices that support overscroll.
** See code in examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.3.dart ** {@end-tool}
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
- SingleChildStatelessModifier
- SliverFillRemainingModifier
- Available extensions
Constructors
Properties
- 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 value cannot be null. This flag is only relevant when the
hasScrollBody value 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
- modifierKey → Key?
-
The actual key of the widget, which Modifier wrapped
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.
inherited
-
buildWithChild(
BuildContext context, Widget? child) → Widget -
A build method that receives an extra
child
parameter.override -
createElement(
) → SingleChildStatelessElement -
Create a SingleChildStatelessElement
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.
inherited
-
modified(
) → Modifier -
Available on Widget, provided by the ModifierTransformer extension
Transform normal widget to Modifier -
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, int wrapWidth = 65}) → 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