Update Scrollable on ScrollBehaviour change.#131164
Update Scrollable on ScrollBehaviour change.#131164auto-submit[bot] merged 1 commit intoflutter:masterfrom
Scrollable on ScrollBehaviour change.#131164Conversation
ae68cd6 to
76899bc
Compare
There was a problem hiding this comment.
Maybe add condition
if((widget.scrollBehavior != null) != (oldWidget.scrollBehavior != null)) {
return true;
}There was a problem hiding this comment.
I think in such a case a call to _updatePosition is made either way, so it's handled.
There was a problem hiding this comment.
I am a bit confused, if oldWidget.scrollBehavior == null but widget.scrollBehavior != null, which code path will call _updatePosition?
There was a problem hiding this comment.
Hey @chunhtai in this case _updatePosition is called from didChangeDependencies.
There was a problem hiding this comment.
Which dependency triggers didChangeDependencies? The scrollBehavior is a pass-in parameter and not a dependency. If you merely changing the pass-in parameter, it won't trigger didChangeDependencies.
There was a problem hiding this comment.
@chinmoy12c can you take a look at this? Thanks!
There was a problem hiding this comment.
Hey @chunhtai @Piinks sorry for the late reply, I've been away for a while.
@chunhtai you are right, the code does not trigger didChangeDependencies, my bad. The actual code that triggers the update is this:
ScrollPhysics? newPhysics = widget.physics ?? widget.scrollBehavior?.getScrollPhysics(context);
ScrollPhysics? oldPhysics = oldWidget.physics ?? oldWidget.scrollBehavior?.getScrollPhysics(context);
In this case either the newPhysics or the oldPhysics is null, hence
if (newPhysics?.runtimeType != oldPhysics?.runtimeType) {
return true;
}
returns true.
There was a problem hiding this comment.
it won't hit this case if both widget.physics and oldWidget.physics are not null even if
oldWidget.scrollBehavior == null and widget.scrollBehavior != null
If it fails to call updatePosition in this case, the _configuration will not be update with the newest widget.scrollBehavior.
There was a problem hiding this comment.
I've removed the approvals while we sort this out. @chinmoy12c maybe we can add a test case for the case @chunhtai mentioned above here to better figure out this fix? :)
Piinks
left a comment
There was a problem hiding this comment.
LGTM! Thank you for fixing this!
|
auto label is removed for flutter/flutter, pr: 131164, due to This PR has not met approval requirements for merging. You are not a member of flutter-hackers and need 1 more review(s) in order to merge this PR.
|
|
Oh whoops! Let me find another reviewer here. :) |
76899bc to
fcaa7b0
Compare
|
Is this ready to be merged? |
fcaa7b0 to
29a5b06
Compare

Fixes: #130793
Pre-launch Checklist
///).