positioned_scroll_observer library

Classes

BoxScrollObserver
When observing RenderBox, axis must be given to indicate the scroll direction. Typically, BoxScrollObserver is used for SingleChildScrollView and ListWheelScrollView that have not RenderSliver between RenderAbstractViewport and its descendants.
ItemScrollExtent
ItemScrollExtent.multi is for items who have an ancestor RenderSliver that has multi child. ItemScrollExtent.single is for the item who has an ancestor RenderSliver that only has on child.
LayoutObserver
Other kinds of observers should extends LayoutObserver to override the functions of onLayout and doFinishLayout that are used in RenderScrollObserverProxy
MultiChildBoxObserver
MultiChildBoxObserver would only observe the closest MultiChildRenderBox ancestor Since the renderObject may not give its children a index, so we store items' size by items' ParentData.hashCode
MultiChildSliverObserver
ObserverProxy<T extends LayoutObserver>
PositionedChildBuilderDelegate
PositionedChildListDelegate
PositionRetainedScrollPhysics
Instead of using a custom ScrollController and ScrollPosition, by using PositionRetainedScrollPhysics, we could avoid breaking out the existing project, and just pass PositionRetainedScrollPhysics as ScrollView.physics. Then, it would not scroll up/down when new items are inserted into the top of a list.
ProxyKey
RenderScrollObserverProxy<T extends LayoutObserver>
RetainableScrollController
A ScrollController enables retaining the current scroll offset. When inserting/adding a new item into the first index of ListView.children, it would scroll up/down pixels that represents the main axis size of the new item, since the ScrollPosition.maxScrollExtent is changed after layouting the new added item. However, the ScrollPosition.pixels does not change, and therefore, the existing items would try to use the old pixels to calculate their painting offsets.
RetainableScrollPosition
ScrollExtent
ScrollObserver
SingleChildBoxObserver
SingleChildSliverObserver
SliverPositionedProxyDelegate
This class extends SliverChildDelegate to allow users to wrap their items conveniently. only when addProxy is true and observer is null, item widgets would be wrapped in ObserverProxy.
SliverScrollObserver

Enums

VisibilityStrategy
if VisibilityStrategy.tolerance, the item would be predicated as visible only when the visible ratio is greater than tolerance. if VisibilityStrategy.inside, the item would be predicted as visible only when the total item is visible in the viewport leadingOffset would be the global scroll Offset for the item starts. trailingOffset would be the global scroll offset that is calculated:leadingOffset + itemSize. leadingEdge is ScrollPosition.pixels, and trailingEdge would be calculated: leadingEdge + SliverConstraints.viewportMainAxisExtent.