-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support floating the header slivers of a NestedScrollView #59187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some doc nit picking...
/// ``` | ||
/// {@end-tool} | ||
/// | ||
/// ## More on using [SliverAppBar]s with [NestedScrollView]s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-Level comment: Reading this entire section, I am wondering if we can shorten this a little bit. Instead of giving longer explanations referring to the internals of the nested scroll view, maybe we can just say in each section whether that type of app bar does or doesn't work out of the box as expected. And if it doesn't work out of the box mention how the scrollview needs to be configured to make it work (the code examples should be left in, of course!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I go back and forth on this. I think it's important to explain a lot of these things, as we often have issues filed that are resolved by just explaining oh you need the SliverOverlap* widgets etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can never have too much documentation, right? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
Sweet! |
@Piinks , I would like to thank you so much for your effort on this feature, just have a question when I moved into this I lost the position.pixels of the CustomScrollView inside the nested because you know I removed the controller from it and kept the nested. I am trying to save the position of the scroll after every restart, I really appreciate your help |
How do i get the HeaderBuilder to build a persistent header on top of my NestedScrollView body. I'm trying to get a transparent effect and there seems to be nothing under the header. ( looks like the inner scroll view is always translated to not fall below it ) |
* Merge flutter/flutter#59187(Support floating the header slivers of a NestedScrollView)
…a NestedScrollView)
Description
Updated PR based on #57707
This PR adds support for floating the outer header slivers of a
NestedScrollView
over the inner scroll view. 🎉This is achieved by introducing
NestedScrollView.floatHeaderSlivers
, a boolean flag for specifying that the header is expected to float. When true, theNestedScrollView
's scrolling coordinator will prioritize the outer scroll view before passing any leftover delta to the inner scroll view.Normally, when an app bar floats, the render object keeps track of a mock scroll offset (_effectiveScrollOffset), since as the app bar moves in and out of view, its position can vary in accordance with the actual scroll offset. Instead of following the mocking convention, as a separate scroll view, we can just change the real offset when floating from a
NestedScrollView
.What is different from #57707 is that the nestedSnap feature has been removed. The solution proposed in #57707 was unfavorable, so instead this documents that floating-snapping SliverAppBars are not supported in the NestedScrollView. You can snap or float, not both. I have filed a issue for this limitation: #59189
There is documentation and sample applications to illustrate use cases in conjunction with the many configurations of a sliver app bar. This change does not address stretching sliver app bars. That is being tracked in #54059, and will come in a follow up change.
Finally, this also makes a small change to the
SliverGeometry.maxScrollObstruction
of theRenderSliverFloatingPinnedPersistentHeader
. The previous geometry set the maxExtent, when it should be the minExtent. Using the maxExtent prevents an expanded, pinned, floating app bar from collapsing as expected.Related Issues
Fixes #49560
Fixes #29264
Fixes #17518
Fixes #20877
Related change: #55069
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.