SimonWang9610/indexed_scroll_observer

[PR]: `ListWheelScrollView` and `SingleChildScrollView` support (break change)

Closed this issue · 1 comments

Currently, all kinds of observers only support scroll views that have a RenderSlvier between items and RenderAbstractViewport, e.g., SliverList, SliverGrid, ListView ad GridView. Therefore, it would require tracking up to find the closest RenderSliver ancestor for observation.

However, such usages do not work on ListWheelScrollView and SingleChildScrollView that do not have a RenderSliver between the viewport and items. So this package should provide a better way to support such kinds of scroll views that do not depend on RenderSliver.

In order to differentiate the two kinds of scroll views (one relying on RenderSliver, while the other does not rely on RenderSliver), this package could create two kinds of observers to support them respectively. For example:

  1. SliverScrollObserver for observing scroll views that rely on RenderSliver.
  2. BoxScrollObserver for observing scroll views that have no RenderSliver between items and its viewport.

Besides, PositionScrollController may make it a little bit complicated to manage multiple observers, so it would be removed directly. Developers should care about creating and managing observers manually, instead of delegating to PositionedScrollController centrally.

To summarize:

  • break changes

    1. PositionedScrollController is removed, and developers should create and manage different observers manually.
    2. Two kinds of observers: SliverScrollObserver and BoxScrollObserver are provided. In contrast, ScrollObserver would be changed into the observer factory that allows developers to create different observers conveniently.
    3. ListWheelScrollView and SingleChildScrollView are supported by using BoxScrollObserver. Developers could find examples at example/.
  • improvements

  1. better estimation for jumping/animating to a specific index. Particularly, items have a fixed item extent.

Merged in ffcaf89