-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix physics with NestedScrollView #11326
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
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.
We need the clamping physics to make nested scroll view work. If you turn off the clamping, it'll go crazy.
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.
What if I want to provide my own class that extends ClampingScrollPhysics? Should we require that the physics argument be a ClampingScrollPhysics?
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.
Specificially, this is the class I'd like to pass: https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/animation/home.dart#L371
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.
Yeah we could just require that the physics extend ClampingScrollPhysics for this subclass.
@abarth may have opinions, the crazy physics inheritance magic is his baby. ;-)
|
I've updated |
88e1dea to
e2c3733
Compare
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.
this sentence's grammar got garbled, not sure what you meant exactly
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.
Defaults to [ClampingScrollPhysics]. is probably better.
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.
Passing a custom class that extends [ClampingScrollPhysics] is allowed. is probably self-evident so I would omit it.
Maybe instead say something like The value must inherit from [ClampingScrollPhysics] and its [ScrollPhysics.applyBoundaryConditions] implementation should not allow scrolling outside the scroll extent range described by the [ScrollMetrics.minScrollExtent]/[ScrollMetrics.maxScrollExtent] properties passed to that method. If that invariant is not maintained, the nested scroll view may respond to user scrolling erratically. or some such.
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 removed this sentence. Maybe consider bringing it back but having it point explicitly to [ScrollPhysics.createBallisticSimulation], which is the main method that one might want to override.
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.
Thinking about it, a better fix (which would allow us to skip all the stuff about forcing the user to use ClampingScrollPhysics et al) would be to just use const ClampingScrollPhysics().applyTo(physics) in the case where physics is non-null.
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.
er, other way around I guess. physics.applyTo(const ClampingScrollPhysics()). Whichever way makes the physics that was passed in take priority. You'd still need to explicitly call out that you shouldn't override the clamping method, though.
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.
This works, so I made the change and reverted my other changes to documentation
e2c3733 to
dee1a33
Compare
dee1a33 to
c705529
Compare
This reverts commit e0f3001.
Fixes #11322
Makes custom physics work with @HansMuller's new
NestedScrollViewdemo.