createSimulation method

Simulation? createSimulation({
  1. 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

Simulation? createSimulation({required bool forward}) {
  assert(
    transitionDuration >= Duration.zero,
    'The `duration` must be positive for a non-simulation animation. Received $transitionDuration.',
  );
  return null;
}