createSimulation method
- required bool forward,
Creates the simulation that drives the transition animation for this route.
By default, this method returns null, indicating that the route doesn't use simulations, but initiates the transition by calling either AnimationController.forward or AnimationController.reverse with transitionDuration and the controller's curve.
Subclasses can override this method to return a non-null Simulation. In this case, the controller will instead use the provided simulation to animate the transition using AnimationController.animateWith or AnimationController.animateBackWith, and the Simulation.x is forwarded to the value of animation. The controller's curve and transitionDuration are ignored.
This method is invoked each time the navigator pushes or pops this route.
The forward
parameter indicates the direction of the transition: true when
the route is pushed, and false when it is popped.
Implementation
@override
Simulation createSimulation({required bool forward}) {
assert(!debugTransitionCompleted(), 'Cannot reuse a $runtimeType after disposing it.');
final double end = forward ? 1.0 : 0.0;
return SpringSimulation(
_kStandardSpring,
controller!.value,
end,
0,
tolerance: _kStandardTolerance,
snapToEnd: true,
);
}