I have a NestedScrollView with a SliverAppBar. The body of the NestedScrollView is a widget with a CustomScrollView with a SliverList.
I want to get the offset from the ScrollController that is given to the NestedScrollView but it only gives me the offset until the SliverAppBar is out of view, but after that the SliverList continues to scroll but the ScrollController doesn't give the offset.
NestedScrollView(
headerSliverBuilder: (_, __) => SliverAppBar(..),
body: RefreshIndicator(
child: CustomScrollView(..),
),
)
The CustomScrollView will automatically use the PrimaryScrollController provided by NestedScrollView.
When a listener is attached to that scroll view, the listener will be called when the SliverAppBar slides into view and out of view until the position.extentAfter is equal to 0.0 and then it will not update at all, no matter how far you scroll down because the extentAfter always remains at 0.0.
How can you retrieve the scroll position of the CustomScrollView inside of the NestedScrollView?
Implementation
It is important that PrimaryScrollController is used because the ScrollController should have the features of PrimaryScrollController. Anyways, in order for the SliverAppBar to work, i.e. it scrolling out of view with the content, the NestedScrollView controller parameter needs to match the CustomScrollView controller (or primary) parameter somehow.
Any implementation that allows the content to be scrolled with PrimaryScrollController.of(context) is fine.
Just note that the NestedScrollView is required in order for the RefreshIndicator to appear below the SliverAppBar.