RotatePageRoute constructor

RotatePageRoute({
  1. required Widget nextPage,
  2. required Widget currentPage,
  3. int numberOfRotations = 1,
  4. bool clockwise = true,
  5. dynamic animationDuration = const Duration(milliseconds: 500),
})

Implementation

RotatePageRoute({
  required this.nextPage,
  required this.currentPage,
  this.numberOfRotations = 1,
  this.clockwise = true,
  animationDuration = const Duration(milliseconds: 500),
}) : super(
        pageBuilder: (context, animation, secondaryAnimation) => nextPage,
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          final double rotationFactor = clockwise ? -1.0 : 1.0;

          return RotationTransition(
            turns: Tween<double>(
              begin: numberOfRotations.toDouble() * rotationFactor,
              end: 0.0,
            ).animate(animation),
            child: animation.value.abs() > 0.5 ? child : currentPage,
          );
        },
        transitionDuration: animationDuration,
      );