Too much refresh in sliverpersistentheader when ChangeNotifiers trigger


I have a flutter app in making with a SliverPersistentHeader (SPH, via delegate, acting as AppBar) which should display updated user-specific score/points/credits. This value get periodically recalculated in background and I get it refreshed via a ChangeNotifier and the ChangeNotificationProvider wrapped around the Widgets build in the Sliver delegate.

Everytime I trigger the notificationListener() it trigger the redraw of the SPH as desired; but it redraw the full sliver content below too and reset the scrolling position.

I have other Sliver items below the header (e.g. a Grid) in which my redraws working as desired and not changing the scrolling of the overall sliver.

Any ideas/hints how I can refresh the SPH without changing the scrolling below ?

Quick update: the SPH contain a stack with positioned widgets; in case this might be of relevance.


ok; my fault in the “business model” … the object I used to store the score also contained other lists shown in the main scroll view. Once I updated the score and called the notificationListener() it redraws the score and lists and reset the scroll position to top.

I took out the values I want to show in the SPH into a different object and react with the redraw on this instance only. This wrapper object is still an element of the application root business object.

This prevent the redraw of the full application which caused the undesired reposition scrolling back to top.

So the issue was not with Sliver but with my lack of experience with provider and the flutter widget tree. Learning each day something new.

Answered By – ChristianVirtual

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *