Animate page transition of old page with secondaryAnimation

22 Views Asked by At

I am using my own GoRouteData and this Pagetransition, where I slide the new page up from the bottom:

class SlideInTransitionPage<T> extends CustomTransitionPage<T> {
  SlideInTransitionPage({
    required super.child,
    super.transitionDuration = const Duration(milliseconds: 500),
    super.reverseTransitionDuration = const Duration(milliseconds: 500),
    super.maintainState = true,
    super.fullscreenDialog = false,
    super.opaque = true,
    super.barrierDismissible = false,
    super.barrierColor,
    super.barrierLabel,
    super.key,
    super.name,
    super.arguments,
    super.restorationId,
  }) : super(
          transitionsBuilder: (context, animation, secondaryAnimation, child) {
            const begin = Offset(0, 1);
            const end = Offset.zero;
            final tween = Tween(begin: begin, end: end).chain(
              CurveTween(
                curve: Curves.easeInOutSine,
              ),
            );
            final offsetAnimation = animation.drive(tween);
            final transitionAnimation = animation.drive(
              TweenSequence([
                TweenSequenceItem(
                  tween: Tween<double>(begin: 0, end: 1),
                  weight: 40,
                ),
                TweenSequenceItem(
                  tween: Tween<double>(begin: 1, end: 1),
                  weight: 65,
                ),
              ]),
            );
            return SlideTransition(
              position: offsetAnimation,
              child: FadeTransition(
                opacity: transitionAnimation,
                child: child,
              ),
            );
          },
        );
}

I would like to have the old page slide up at the same time (a bit slower). I read this answer but I don't understand it. How do I use the secondaryAnmiation for that?.

0

There are 0 best solutions below