Update any in-progress scrolling physics to account for new scroll behavior.
The scrolling physics depends on the scroll behavior. When changing the scrolling behavior, call this function to update any in-progress scrolling physics to account for the new scroll behavior. This function preserves the current velocity when updating the physics.
If there are no in-progress scrolling physics, this function scrolls to the given offset instead.
Source
void didUpdateScrollBehavior(double newScrollOffset) {
_setStateMaybeDuringBuild(() {
_contentExtent = scrollBehavior.contentExtent;
_containerExtent = scrollBehavior.containerExtent;
});
// This does not call setState, because if anything below actually
// changes our build, it will itself independently trigger a frame.
assert(_controller.isAnimating || _simulation == null);
if (_numberOfInProgressScrolls > 0) {
if (_simulation != null) {
double dx = _simulation.dx(_controller.lastElapsedDuration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND);
_startToEndAnimation(dx); // dx - logical pixels / second
}
return;
}
scrollTo(newScrollOffset);
}