Get if header is currently pinned
felixjaehn opened this issue · 4 comments
Thank you for this package. I have used this to achieve great results with the extended Sliver functionality. But I would love to ask one thing: Is it currently possible to get information on wether the SliverPersistendHeader is currently pinned or not. I would love to know that, because I then can adjust the header depending on whether the list below is currently visible or not.
And one little bonus I would love to know is if it is possible to expand the list below the header by tapping on the SliverPersistentHeader. If there is no default implementation for this I would use the scroll Controller for this.
Thanks!
For both questions that’s a no at the moment.
Could you perhaps elaborate (maybe with some code) on what you’re trying to achieve?
I added a picture to visualize the desired behavior. I am currently building a checkout process and would like to achieve that the already completed components are minimized but remain as SliverPersistentHeader. For this it is necessary that I can display the header differently depending on the status (show or not show a checkmark). The segment should get minimized if the user scrolls past the area of the segment. At the end every segment of the scrollable area every segment except the last one should therefore be closed.
To achieve this I was thinking of using the scrollControllers offset to calculate which header should be shown, but by doing so I realized that this would be a very unpleasant solution.
So I was hoping to have a simpler way to evaluate which header style to show
MultiSliver(
children: <Widget>[
SliverPinnedHeader(child: someBoolToEvaluate?CardHeaderWidget(title: section.title) : OtherCardHeaderWidget),
SliverClip(
child: MultiSliver(
children: <Widget>[
buildForm(),
],
),
),
],
);
I hope that I have succeeded in describing the desired behavior. Unfortunately, since I'm still quite a beginner, it can also be that I overlook a completely obvious solution.
Thanks!
Have you tried using the SliverPersistantHeader that is in the flutter framework itself?
That one allows you to build the widget differently depending on the shrinkOffset
, I think it should be possible to get what you want using that. It does require you to calculate the height of the sliver yourself though
The normal SliverPersistantHeader has been the way to go. Sorry for the confusion!