mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
I'd like to have a scroll activity that drives the scroll view through a particular animation -- just like a DrivenScrollActivity does -- but where the animation doesn't have an end point or duration that's known when the animation begins. (Concretely, this is to implement a "scroll to the end of history" button in the Zulip message list. The end point is maxScrollExtent... except that maxScrollExtent while in the middle of history is only an estimate, and will change as the list view scrolls through shorter and longer messages.) That means the animation is naturally described by a Simulation, but not by the parameters accepted by the current DrivenScrollActivity constructor, or by the animateTo method which wraps it. I think this can be handled quite cleanly with an alternate constructor on DrivenScrollActivity, one that accepts a Simulation instead of the from/to/duration/curve parameters accepted by the default constructor. The new constructor is very similar to the constructor of BallisticScrollActivity. Most of the changes here are in revising the docs of both DrivenScrollActivity and BallisticScrollActivity. The docs had characterized the difference between the two as about using a Simulation vs. the from/to/duration/curve animation parameters, but I think that's never been the most important difference between them: the key difference is really the `goBallistic` calls in BallisticScrollActivity, particularly in `applyNewDimensions`, and the implications those have for how the simulation needs to relate to the scroll physics. So this rewrites the docs to describe that.