goBallistic method
Start a physics-driven simulation that settles the pixels position, starting at a particular velocity.
This method defers to ScrollPhysics.createBallisticSimulation, which typically provides a bounce simulation when the current position is out of bounds and a friction simulation when the position is in bounds but has a non-zero velocity.
The velocity should be in logical pixels per second.
Implementation
@override
void goBallistic(double velocity) {
// A velocity is consumed by nested scroll.
velocity = velocity - _fling(velocity);
// Fixed an issue for #3:
// https://github.com/MTtankkeo/flutter_appbar/issues/3
if (velocity.abs() == 0 && activity is DragScrollActivity) {
isNestedScrolling = false;
}
// Fixed an issue for #6
// https://github.com/MTtankkeo/flutter_appbar/issues/6
if (activity is IdleScrollActivity) {
isNestedScrolling = false;
}
// When infinite scrolling is already possible, there is no need to replace
// the [BallisticScrollActivity] instance even if the size has changed.
if (velocity != 0 &&
isNestedScrolling &&
activity is BallisticNestedScrollActivity) {
return;
}
assert(hasPixels);
final Simulation? simulation = physics.createBallisticSimulation(
// If it's true, must begin non-clamping scrolling.
isNestedScrolling
? copyWith(
minScrollExtent: -double.infinity,
maxScrollExtent: double.infinity,
pixels: totalPixels,
)
: copyWith(pixels: totalPixels),
velocity);
if (simulation != null) {
beginActivity(BallisticNestedScrollActivity(
this,
simulation,
context.vsync,
activity?.shouldIgnorePointer ?? true,
));
} else {
goIdle();
}
}