OpacityScalePageTransition<T> constructor

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

Implementation

OpacityScalePageTransition({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 rotationMaxDegrees =
              30.0; // Adjust the maximum rotation angle as desired
          final rotationAnimation = Tween<double>(
            begin: -rotationMaxDegrees,
            end: 0.0,
          ).animate(animation);

          const initialScale =
              0.8; // Adjust the initial scale factor as desired
          const endScale = 1.0;
          final scaleAnimation = Tween<double>(
            begin: initialScale,
            end: endScale,
          ).animate(animation);

          var fadeTween = Tween(begin: 0.0, end: 1.0);
          final fadeAnimation = fadeTween.animate(animation);

          return FadeTransition(
            opacity: fadeAnimation,
            child: Transform.scale(
              scale: scaleAnimation.value,
              child: Transform.rotate(
                angle: rotationAnimation.value * (math.pi / 180),
                alignment: Alignment.centerRight,
                child: SlideTransition(
                  position: offsetAnimation,
                  child: child,
                ),
              ),
            ),
          );
        },
      );