RotationPageTransition<T> constructor

RotationPageTransition<T>({
  1. required Widget page,
})

Implementation

RotationPageTransition({required this.page})
    : super(
        pageBuilder: (context, animation, secondaryAnimation) => page,
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          const begin = Offset(1.0, 0.0);
          const end = Offset.zero;
          const curve = Curves.easeInOut;
          var tween =
              Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
          var offsetAnimation = animation.drive(tween);

          const rotateCurve = Curves.easeInOut;
          var rotateTween = Tween(begin: 0.0, end: 1.0)
              .chain(CurveTween(curve: rotateCurve));
          final rotateAnimation = animation.drive(rotateTween).value * 360.0;

          const scaleCurve = Curves.easeInOut;
          var scaleTween = Tween(begin: 0.8, end: 1.0)
              .chain(CurveTween(curve: scaleCurve));
          final scaleAnimation = animation.drive(scaleTween);

          return Transform.scale(
            scale: scaleAnimation.value,
            child: Transform.rotate(
              angle: rotateAnimation * (math.pi / 180),
              child: SlideTransition(
                position: offsetAnimation,
                child: child,
              ),
            ),
          );
        },
      );