ScaleSlideTransition<T> constructor

ScaleSlideTransition<T>({
  1. required Widget page,
  2. required bool isLeftScaled,
})

Determines whether to scale from the left or right. Constructor for the ScaleSlideTransition class.

Implementation

/// Constructor for the ScaleSlideTransition class.
ScaleSlideTransition({required this.page, required this.isLeftScaled})
    : super(
        pageBuilder: (context, animation, secondaryAnimation) => page,
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          final begin =
              isLeftScaled ? const Offset(1.0, 0.0) : const Offset(-1.0, 0.0);
          const end = Offset.zero;
          const curve = Curves.easeInOut;
          final tween =
              Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
          final offsetAnimation = animation.drive(tween);

          final scaleValue = Tween<double>(
            begin: isLeftScaled ? 0.8 : 1.2,
            end: 1.0,
          ).animate(animation);

          return AnimatedBuilder(
            animation: animation,
            builder: (context, child) {
              return Transform.scale(
                scale: scaleValue.value,
                child: SlideTransition(
                  position: offsetAnimation,
                  child: child,
                ),
              );
            },
            child: child,
          );
        },
      );