ElasticRotationTransition<T> constructor

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

Implementation

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

          final rotationValue = Tween<double>(
            begin: -0.2,
            end: 0.0,
          ).animate(animation);

          final stretchValue = Tween<double>(
            begin: 1.2,
            end: 1.0,
          ).animate(animation);

          return RotationTransition(
            turns: AlwaysStoppedAnimation(rotationValue.value),
            child: ScaleTransition(
              scale: stretchValue,
              child: SlideTransition(
                position: offsetAnimation,
                child: child,
              ),
            ),
          );
        },
      );