SliverMainAxisGroup class
A sliver that places multiple sliver children in a linear array along the main axis, one after another.
Layout algorithm
This section describes how the framework causes RenderSliverMainAxisGroup to position its children.
Layout for a RenderSliverMainAxisGroup has four steps:
- Keep track of an offset variable which is the total SliverGeometry.scrollExtent of the slivers laid out so far.
- To determine the constraints for the next sliver child to layout, calculate the amount of paint extent occupied from 0.0 to the offset variable and subtract this from SliverConstraints.remainingPaintExtent minus to use as the child's SliverConstraints.remainingPaintExtent. For the SliverConstraints.scrollOffset, take the provided constraint's value and subtract out the offset variable, using 0.0 if negative.
- Once we finish laying out all the slivers, this offset variable represents the total SliverGeometry.scrollExtent of the sliver group. Since it is possible for specialized slivers to try to paint itself outside of the bounds of the sliver group's scroll extent (see SliverPersistentHeader), we must do a second pass to set a SliverPhysicalParentData.paintOffset to make sure it is within the bounds of the sliver group.
- Finally, set the RenderSliverMainAxisGroup.geometry with the total SliverGeometry.scrollExtent, SliverGeometry.paintExtent calculated from the constraints and SliverGeometry.scrollExtent, and SliverGeometry.maxPaintExtent.
In this sample the CustomScrollView renders a SliverMainAxisGroup and a
SliverToBoxAdapter with some content. The SliverMainAxisGroup renders a
SliverAppBar, SliverList, and SliverToBoxAdapter. Notice that when the
SliverMainAxisGroup goes out of view, so does the pinned SliverAppBar.
link
To create a local project with this code sample, run:
flutter create --sample=widgets.SliverMainAxisGroup.1 mysample
See also:
- SliverPersistentHeader, which is a RenderObjectWidget which may require adjustment to its SliverPhysicalParentData.paintOffset to make it fit within the computed SliverGeometry.scrollExtent of the SliverMainAxisGroup.
- SliverCrossAxisGroup, which is the RenderObjectWidget for laying out multiple slivers along the cross axis.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- RenderObjectWidget
- MultiChildRenderObjectWidget
- SliverMainAxisGroup
Constructors
-
SliverMainAxisGroup({Key? key, required List<
Widget> slivers}) -
Creates a sliver that places sliver children in a linear array along
the main axis.
const
Properties
-
children
→ List<
Widget> -
The widgets below this widget in the tree.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
-
createElement(
) → MultiChildRenderObjectElement -
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
inherited
-
createRenderObject(
BuildContext context) → RenderSliverMainAxisGroup -
Creates an instance of the RenderObject class that this
RenderObjectWidget represents, using the configuration described by this
RenderObjectWidget.
override
-
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
-
didUnmountRenderObject(
covariant RenderObject renderObject) → void -
A render object previously associated with this widget has been removed
from the tree. The given RenderObject will be of the same type as
returned by this object's createRenderObject.
inherited
-
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
-
updateRenderObject(
BuildContext context, covariant RenderObject renderObject) → void -
Copies the configuration described by this RenderObjectWidget to the
given RenderObject, which will be of the same type as returned by this
object's createRenderObject.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited