pushReplacement static method

void pushReplacement(
  1. ParentAnimation animation
)

Constructs a Navigator object that pushes a new page onto the navigation stack with a custom transition animation and replaces the current page. The animation parameter is an instance of a ParentAnimation class that defines the animation to be used. The animation parameter can be any of the following types:

Implementation

static void pushReplacement(ParentAnimation animation) {
  switch (animation) {
    // - [FadeScaleAnimation]
    case FadeScaleAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        FadeScalePageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          initialScale: anim.initialScale,
          animationDuration: anim.duration,
        ),
      );
      break;

    // - [FlipAnimation]
    case FlipAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        FlipPageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          animationDuration: anim.duration,
          axis: anim.axis,
          fadeIn: anim.fadeIn,
          forward: anim.forward,
        ),
      );
      break;

    // - [FlyInAnimation]
    case FlyInAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        FlyInPageRoute(
          nextPage: animation.nextPage,
          currentPage: animation.context.widget,
          animationDuration: animation.duration,
          axis: anim.axis,
          inclination: anim.inclination,
          fadeIn: anim.fadeIn,
          forward: anim.forward,
        ),
      );
      break;

    // - [SlideAnimation]
    case SlideAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        SlidePageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          animationDuration: anim.duration,
          direction: anim.direction,
        ),
      );
      break;

    // - [RotateAnimation]
    case RotateAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        RotatePageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          animationDuration: anim.duration,
          numberOfRotations: anim.numberOfRotations,
          clockwise: anim.clockwise,
        ),
      );
      break;

    // - [SwirlAnimation]
    case SwirlAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        SwirlPageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          animationDuration: anim.duration,
          numberOfHalfRotations: anim.numberOfHalfRotations,
          forward: anim.forward,
          axis: anim.axis,
        ),
      );
      break;

    // - [CornerAnimation]
    case CornerAnimation anim:
      Navigator.pushReplacement(
        anim.context,
        CornerPageRoute(
          nextPage: anim.nextPage,
          currentPage: anim.context.widget,
          animationDuration: anim.duration,
          corner: anim.corner,
        ),
      );
      break;
  }
}