BlinkPageTransition<T> constructor

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

Implementation

BlinkPageTransition({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));
          final offsetAnimation = animation.drive(tween);

          // const blinkDuration = Duration(milliseconds: 200); // Adjust the blink duration as desired
          const blinkInterval = Interval(0.0, 0.2, curve: Curves.easeInOut);

          final isBlinking = animation.value >= blinkInterval.begin &&
              animation.value <= blinkInterval.end;

          return AnimatedBuilder(
            animation: animation,
            builder: (context, child) {
              return Opacity(
                opacity: isBlinking ? 0.0 : 1.0,
                child: Transform.translate(
                  offset: offsetAnimation.value,
                  child: child,
                ),
              );
            },
            child: child,
          );
        },
      );