RenderSliveris the base class used by render objects that implement scrolling effects. Layout utilizes
RenderSliver.geometry); painting is unchanged, with the origin positioned at the top-left corner. Hit testing is implemented similarly to
RenderBox, relying instead on extents within the viewport’s main axis.
RenderSliverHelpersincorporates a variety of helpers, including support for implementing
RenderObject.hitTestChildrenfor slivers with box children.
RenderSliverToBoxAdapteradapts a render box to the sliver protocol, allowing it to appear alongside and within other slivers.
RenderSliverPadding, have a single sliver child. Few slivers have multiple sliver children (generally, this is the purview of viewports).
RenderSliver.calculatePaintOffsetaccept a region (defined by a “from” and “to” relative to the sliver’s zero offset) and determine the contained extent that is visible. This value is derived from the current scroll offset and remaining paint/cache extent from the provided constraints.
RenderSliver.getAbsoluteSizeRelativeToOrigin: the size of the sliver in relation to the sliver’s leading edge rather than the canvas’s origin. This size is derived from the cross axis and paint extents; the paint extent is negated if the sliver’s contents precede its leading edge from the perspective of the canvas.
RenderSliver.childScrollOffset: the distance from the parent’s zero scroll offset to a child’s zero scroll offset; unaffected by scrolling. Defaults to returning zero (i.e., child and parent are aligned).
RenderSliver.childMainAxisPosition: the distance from the parent’s visible leading edge to the child’s visible leading edge, in the axis direction. If the actual leading edge is not visible, the edge defined by the intersection of the sliver with the viewport’s leading edge is used instead. The child must be visible, though the parent need not be (e.g., a persistent header that pins its child even when the anchoring sliver is scrolled away).
RenderSliver.childCrossAxisPosition: for vertical axes, this is the distance from the parent’s left side to the child’s left side. For horizontal axes, this is the distance from parent’s top side to the child’s top side.
RenderSliver.geometryis analogous to
RenderBox.sizeand contains the output of layout.
RenderSliver.centerOffsetAdjustmentis an offset applied to the viewport’s center sliver (e.g., to center it). Implicitly shifts neighboring slivers. Positive offsets shift the sliver opposite the axis direction.
SliverPhysicalParentData.paintOffset) or using a delta from the parent’s zero scroll offset to the nearest child edge (via
SliverLogicalParentData.layoutOffset). The former optimizes painting at the expense of layout whereas the latter makes the opposite trade-off.
RenderBox, tracking whether a point is contained within the current sliver or one of its descendents. The current sliver determines whether this is the case by first testing its children and then itself (
SliverHitTestResult, and returns true. The sliver will then receive subsequent pointer events via
SliverHitTestEntryassociates a sliver with the coordinate that was hit.
HitTestResultwith a convenience method for mapping to sliver coordinates (
SliverHitTestResult.addWithAxisOffset). This adapts a main and cross axis position in the parent’s coordinate space to the child’s coordinate space by subtracting the offset to the child. A paint offset is also used since
HitTestResultis also responsible for mapping pointer events, which use canvas coordinates. [?]
SliverConstraints.asBoxConstraints. This method accepts minimum and maximum bounds for the sliver’s main extent (e.g., if the main axis is horizontal, this would correspond to width). The cross axis constraint is always tight.
SliverConstraints.crossAxisDirection: the current orientation and directionality of the main and cross axes.
SliverConstraints.growthDirection: how a sliver’s contents are ordered relative to the main axis direction (i.e., first-to-last vs. last-to-first).
SliverConstraints.normalizedGrowthDirection: the growth direction that would produce the same child ordering assuming a “standard” axis direction (
AxisDirection.right). This is the opposite of
SliverConstraints.growthDirectionif axis direction is up or left.
SliverConstraints.cacheOrigin: how far before the current scroll offset to begin painting to support caching (i.e., the number of pixels to “reach back” from the first visible offset in the sliver). Always between -
SliverConstraints.overlap: a delta from the current scroll offset to the furthest pixel that has not yet been painted by an earlier sliver, in the axis direction. For example, if an earlier sliver painted beyond its layout extent, this would be the offset to “escape” that painting. May be negative if the furthest pixel painted precedes the current sliver (e.g., due to overscroll).
SliverConstraints.precedingScrollExtent: the total scrolling distance consumed by preceding slivers (i.e., the sum of all preceding scroll extents). Scroll extent is approximate for slivers that could not fully paint in the available space; thus, this value may be approximate. If a preceding sliver is built lazily (e.g., a list that builds children on demand) and has not finished building, this value will be infinite. It may also be infinite if a preceding sliver is infinitely scrollable.
SliverConstraints.remainingPaintExtent: the number of pixels available for painting in the viewport. May be infinite (e.g., for shrink-wrapping viewports). Zero when all pixels have been painted (e.g., when a sliver is beyond the viewport’s trailing edge).
SliverConstraints.remainingCacheExtent: the number of pixels available for painting in the viewport and cache regions, starting from the scroll offset adjusted by the cache origin. Always larger than remaining paint extent.
SliverConstraints.scrollOffset: the offset of the first visible part of the sliver, as measured from the sliver’s leading edge in the axis direction. Equivalently, this is how far the sliver’s leading edge precedes its parent’s leading edge.
ScrollDirectionin relation to the axis direction and the content’s logical ordering (as determined by growth direction).
ScrollDirection.reverse. If the content were reversed within that web page, it would be
SliverConstraints.viewportMainAxisExtent: the number of pixels that the viewport can display in its main axis.
SliverLogicalParentData, respectively). Though a sliver may have a particular position, it is free to paint anywhere in the viewport.
SliverGeometry.paintOrigin: where to begin painting relative to the sliver’s current layout position, expressed as an offset in the axis direction (e.g., a negative value would precede the current position).
SliverGeometry.paintExtent: the number of contiguous pixels consumed by this sliver in the visible region. Measured from the sliver’s layout position, as adjusted by the paint origin (
SliverGeometry.paintOrigin, typically zero).
SliverGeometry.maxPaintExtent: the number of pixels this sliver could paint in an unconstrained environment (i.e., a shrink-wrapping viewport). Approximate.
SliverGeometry.layoutExtent: the number of contiguous pixels consumed by this sliver in the visible region for layout (i.e., the amount of space this sliver will physically occupy in the viewport). Measured from the sliver’s layout position regardless of paint origin. Layout positions are advanced by summing layout extents.
SliverGeometry.scrollExtent: the amount of scrolling needed to reach this sliver’s trailing edge from its leading edge. Used to calculate all subsequent sliver’s scroll offsets.
SliverGeometry.cacheExtent: the number of contiguous pixels consumed by this sliver in the cacheable region. Measured from the sliver’s layout position, as adjusted by the cache origin (i.e., the offset into the available cache region from the sliver’s current scroll offset).
SliverGeometry.hitTestExtent: the number of contiguous pixels painted by this sliver that are interactive in the visible region. Measured from the sliver’s layout position. Does not take the paint origin into account.
RenderSliver.hitTestwhich might, for instance, take into account paint origin; if applicable, the parent sliver must be written to forward hit events that fall outside of its own interactive bounds.
SliverGeometry.maxScrollObstructionExtent: only meaningful for slivers that affix themselves to the leading or trailing edges of the viewport (e.g., a pinned header), effectively reducing the amount of content visible within the viewport (i.e., the viewport’s outer dimension). If applicable, this is the extent of that reduction, in pixels.
SliverGeometry.hasVisualOverflow: whether a clip is necessary due to visual overflow. The viewport will add a clip if any of its children report visual overflow.
SliverGeometry.visible: whether this sliver should be painted. Defaults to true when paint extent is greater than zero.
SliverGeometry.scrollOffsetCorrection: a correction indicating that the incoming scroll offset was invalid (e.g., [?]) and therefore must be corrected. If set, no further geometry need be returned as layout will be recomputed from scratch. Must be propagated to the containing viewport.
SliverToBoxAdapteris a single-child render object widget that incorporates a
RenderSliverToBoxAdapterinto the render tree.
RenderSliverSingleBoxAdapterlays the groundwork for managing a single render box child.
SliverPhysicalParentData); these coordinates are measured from the parent’s visible top-left corner to the child’s visible top-left corner.
RenderSliverSingleBoxAdapter.setChildParentData). This calculation takes into account that render boxes may be partially off screen and must therefore be offset during painting to ensure that the correct slice of the box is visible.
RenderSliverSingleBoxAdapterand does the actual work of adapting the sliver layout protocol to the render box equivalent.
RenderSliverPadding: adds padding around a child sliver.
SliverGeometry.scrollExtent: decreased to reflect leading padding pushing content toward the viewport’s leading edge.
SliverGeometry.cacheOrigin: offset to reflect padding consuming cache space.
SliverGeometry.remainingCacheExtent: reduced by any leading padding that is visible.
SliverGeometry.crossAxisExtent: reduced by the total cross axis padding.
SliverGeometry.paintExtent: either the total visible main axis padding plus the child’s layout extent or, if larger, the leading padding plus the child’s paint extent (this would allow the child’s painting to overflow trailing padding). Clamped to remaining paint extent.
SliverGeometry.scrollExtent:the child’s scroll extent plus main axis padding.
SliverGeometry.layoutExtent: the total visible main axis padding plus the child’s layout extent. Clamped to the paint extent (i.e., cannot consume more space than is painted).
SliverGeometry.hitTestExtent: the total visible main axis padding plus the child’s paint extent or, if larger, the leading padding plus the child’s hit testing extent (allowing the child’s hit testing region to overflow).
RenderSliverFillRemainingis a single box adapter that causes its child to fill the remaining space in the viewport. Subsequent slivers are never seen as this sliver consumes all usable space.
RenderSliverToBoxAdapterwhich leaves the main extent unconstrained). The child is subsequently laid out.
SliverGeometry.scrollExtent: the full extent of the viewport. This is an upper bound since it isn’t actually possible to scroll beyond this sliver: it consumes all viewport space.
SliverGeometry.layoutExtent: matches the extent of the child that fits within the viewport.