MultiChildSliverObserver class

Inheritance

Constructors

MultiChildSliverObserver({int? itemCount})

Properties

axis Axis
isRevealed may use this to calculate the trailing offset for an item
no setterinherited
firstLayoutFinished bool
if the first layout is completed. it should be true as long as doFinishLayout is invoked at least once. once firstLayoutFinished is true, indicating that all operations on this observer could be completed safely.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isActive bool
indicates whether a RenderSliver is being observed by this observer. If false, it would throw errors to report illegal usage, only when isActive is true, the observer could work normally.
no setterinherited
isObserving bool
no setterinherited
itemCount int?
getter/setter pairinherited
items Map<int, ItemScrollExtent>
the items whose ItemScrollExtent have been observed after doFinishLayout
no setterinherited
mainAxisExtent double
the available painting extent along the main axis for a viewport
no setterinherited
origin RevealedOffset?
the origin of RenderObject that is being observed
getter/setter pairinherited
renderObject RenderSliver?
RenderObject is being observed
no setterinherited
renderToTargetIndex ↔ IndexConverter?
sometimes, the render index may not be the target index to which users want to scroll. by setting renderToTargetIndex, users could define how to convert the render index to the target index.
getter/setter pairinherited
renderVisible bool
if the observing RenderSliver is visible in its closest ancestor RenderViewportBase
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldDoFinishLayout bool
once onLayout is invoked, it would be true to indicate that it require invoking doFinishLayout at least once. Users typically do not set shouldDoFinishLayout directly.
getter/setter pairinherited
shouldUpdateOrigin bool
no setterinherited
sizes Map<int, Size>
the Size of laid out children, the key may be its index for SliverScrollObserver, or ParentData.hashCode for BoxScrollObserver
no setterinherited
targetToRenderIndex ↔ IndexConverter?
sometimes, the target index to which users want to scroll may not be same as the current render index, by using targetToRenderIndex, users could define how to map the target index to a render index. e.g., when using ListView.separated, the item index may not be equal to its render index, since separators would be also counted as the children of RenderSliver.
getter/setter pairinherited

Methods

alignVisibleOffset(double alignment) RevealedOffset?
Calculate the position of renderObject using the given alignment See also:
inherited
animateToIndex(int index, {required ScrollPosition position, required Duration duration, required Curve curve, bool closeToEdge = true, double alignment = 0.0}) Future<bool>
animate to index based on the given position.
inherited
checkFirstLayoutFinished() → void
ensure firstLayoutFinished is true to guarantee legal usage for estimateScrollOffset before continuing
inherited
clear() → void
inherited
doFinishLayout() → void
active items have been laid out, and some of them are painting, at this time, we know the layout for renderObject must be completed, so we could doFinishLayout safely
override
estimateScrollOffset(int target, {required ScrollExtent scrollExtent}) double
estimate the scroll offset for target based on either its ItemScrollExtent or _averageExtentForEachIndex. Use _first or _last to indicate if scroll up or scroll down. The final estimation would be clamped between ScrollExtent.min and ScrollExtent.max to avoid over scrolling.
inherited
getItemScrollExtent(int index) ItemScrollExtent?
get the observed ItemScrollExtent for index
inherited
getItemSize(int index) Size?
Different observers may override getItemSize base on how they store sizes of items. e.g., BoxScrollObserver would override this method since sizes's key is ParentData.hashCode instead of its index
inherited
getMainAxisExtent(int index) double
get the index's main axis extent based on axis
inherited
getTrailingEdgeFromScroll(ScrollExtent scrollExtent) double
if the viewport is overlapped by the previous RenderSliver, the trailing edge should subtract the overlapped area
inherited
getVisibleItems({required ScrollExtent scrollExtent, VisibilityStrategy strategy = VisibilityStrategy.tolerance}) List<int>
inherited
isDesiredParentData(ParentData? parentData) bool
check if parentData is desired for an observer. it should be implemented by the subclasses of LayoutObserver
override
isDesiredRenderObject(RenderObject renderObject) bool
inherited
isRevealed(int index, {required ScrollExtent scrollExtent, VisibilityStrategy strategy = VisibilityStrategy.tolerance, double tolerance = 0.1, bool shouldNormalized = true, bool shouldConvert = false}) bool
if index is revealed in its closest ancestor RenderSliver. typically, index must have been observed before checking isRevealed.
inherited
jumpToIndex(int index, {required ScrollPosition position, bool closeToEdge = true, double alignment = 0.0}) → void
jump to index based on the given position. this observer and position should be associated/attached to the same ScrollController. if closeToEdge is true, we would try scrolling index to the edge of ScrollView.reverse if not over scrolling. alignment only takes effects when the observed RenderObject is not visible on the screen, if the RenderObject has been visible on the screen, alignment is ignored.
inherited
normalizeIndex(int index) int
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onLayout(RenderObject value, {required Size size, ParentData? parentData}) → void
If it observes multiple scrollable children set renderObject if both are not identical, and mark shouldUpdateOrigin as true to do _updateRenderOrigin. Meanwhile, it should mark shouldDoFinishLayout as true since some items are laid out
override
pause() → void
sometimes, ObserverProxy may not be descendants of RenderSliver temporarily, e.g., ReorderableListView is ordering. using pause to stop observing temporarily.
inherited
relativePositionInViewport(int index, {required ScrollExtent scrollExtent, double alignment = 0.0, bool shouldNormalized = true, bool shouldConvert = false}) double?
inherited
resume() → void
using resume to continue observing.
inherited
showInViewport(ViewportOffset offset, {double alignment = 0.0, Duration duration = Duration.zero, Curve curve = Curves.ease}) → void
make its observed RenderObject visible in its closest ancestor RenderViewportBase we guarantee that RenderAbstractViewport.of would find an RenderAbstractViewport ancestor, since the scrollable content is always wrapped in a kind of RenderAbstractViewport. alignment indicates how you want to align the RenderObject on the screen when RenderObject is visible. if alignment is 0.0, RenderObject would try closing to ScrollPosition.pixels as much as possible; if alignment is 1.0, RenderObject would try closing to ScrollPosition.maxScrollExtent as much as possible; if alignment is 0.5, RenderObject would try closing to the center between ScrollPosition.pixels and ScrollPosition.maxScrollExtent as much as possible.
inherited
toString() String
A string representation of this object.
inherited
updateEstimation(double totalExtent, int count) → void
average _averageExtentForEachIndex based on the current observed totalExtent, maybe we should have a better way to summarize the previous estimation: _averageExtentForEachIndex and the current exact extent: totalExtent
inherited
updateMaxCrossCount({required int maxCrossCount, required double maxCrossOffset, required double crossAxisExtent}) → void
maxCrossOffset is cross axis offset of the left/bottom most item maxCrossCount increments when maxCrossOffset increments
inherited
updateRange(int? first, int? last) → void
record those children that have been laid out
inherited
visibleRatioInViewport(ScrollExtent scrollExtent) double
calculate the visible part of the RenderObject relative to the main axis extent of its viewport. for example, the observed RenderObject has 200 pixels painted on the screen, while the viewport has 500 pixels painting extent. The ratio would be 200/500 = 0.4. The result would never over 1.0, since the visible part can not be greater than the viewport's painting extent. typically, it is used for multi slivers in a custom scroll view to see if how many ratio of which the sliver is visible in the viewport
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited