SliverAppBar - Configurable overscroll stretch with callback feature & FlexibleSpaceBar support#42250
Merged
Piinks merged 25 commits intoflutter:masterfrom Nov 5, 2019
Merged
SliverAppBar - Configurable overscroll stretch with callback feature & FlexibleSpaceBar support#42250Piinks merged 25 commits intoflutter:masterfrom
Piinks merged 25 commits intoflutter:masterfrom
Conversation
Contributor
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Contributor
Author
|
cc/ @HansMuller FYI 🙂 |
justinmc
approved these changes
Oct 28, 2019
Contributor
justinmc
left a comment
There was a problem hiding this comment.
I'm no sliver expert but LGTM 👍
Just some small suggestions here and there.
packages/flutter/lib/src/rendering/sliver_persistent_header.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/rendering/sliver_persistent_header.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/rendering/sliver_persistent_header.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/rendering/sliver_persistent_header.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/material/flexible_space_bar_stretch_mode_test.dart
Show resolved
Hide resolved
Inconnu08
pushed a commit
to Inconnu08/flutter
that referenced
this pull request
Nov 26, 2019
…& FlexibleSpaceBar support (flutter#42250)
|
@Piinks Would this allow a Google Maps instance inside a SliverAppBar, instead of an image? I tried many approaches in the pass with no success. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SliverAppBar.stretch
This PR introduces the ability to configure a stretch effect for a
SliverAppBarwhen usingScrollPhysicsthat allow overscroll. (i.e. iOS'sBouncingScrollPhysics).This configuration also allows you to specify an amount of overscroll offset that will trigger a given callback function. The default triggering offset distance is 100.0.
This stretch features works with all of the
SliverAppBarconfigurations - floating, pinned, snap, and default scrolling persistent headers all work with stretch.FlexibleSpaceBar
Potential follow-up on this would be to add something along the lines of a stretchMode toFlexibleSpaceBar, similar to the collapseMode that is already provided.The
SliverAppBarchanges alone would leave theFlexibleSpaceBarin a weird state when using the stretch feature, so I have added support here as well.This support comes in the form of
StretchModes, modeled after theCollapseModes that are already a part ofFlexibleSpaceBar. Currently being added here are zoomBackground, blurBackground, and fadeTitle, all of which are in use in the animation below. Providing at least the zoomBackground stretch mode seems prudent since without it an app bar will stretch outside of the background. These stretch modes do not interfere with any of the collapse modes.Code snippet behind this animation:
More Custom Stretching!
While the stretch modes introduced here may not cover every possible stretch behavior, the changes to
SliverAppBaralone make it much easier to implement your own custom behavior for stretching, as the proper constraints will be passed down from theSliverPersistentHeaderto any of its children when stretch is true. For example, the Pesto demo of Flutter Gallery automatically adheres to the stretch, using aLayoutBuilderinstead of aFlexibleSpaceBar. Shown here:A follow-up PR will add animated illustrations to go along with sample code.
Related Issues
Fixes #27373
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
Does your PR require Flutter developers to manually update their apps to accommodate your change?