1

When combining SliverAppBar with some tabs in NestedScrollView, using PageStorageKey may not hold scroll postion.

Pattern A:

Scroll the Left tab to the middle and switch to the Right tab. Scroll Right tab to the middle and back to Left tab. In this case, Left tab holds scroll position.

Pattern B:

Scroll the Left tab to the middle and switch to the Right tab. Display the top of the Right tab and scroll up, return to the Left tab. In this case, the Left tab does not hold the scroll position (Scroll position will be 0)

Regardless of which tab you are displaying, scroll to the top and expand the SliverAppBar. The position of all ScrollViews in NestedScrollview seems to be reset to the top.

Even in the case of pattern B, How do I keep the left tab scroll position?

This is my code. https://gist.github.com/ysknsn/d90a84a180e32de5b0691de874c65d55

This is the screenshot. enter image description here (SliverAppBar is shrink when you scrol down, and expand when you scroll up)

Any advices are helpful. Thanks.

ysknsn
  • 89
  • 2
  • 10

1 Answers1

0

Have you tried to store current scroll offset of the scroll controllers in your state? Then you can pass this value as an initial scroll offset in the build method.

Heisenbug
  • 951
  • 6
  • 25