NavigateRoute constructor

NavigateRoute(
  1. Widget widget, {
  2. bool? rootNavigator,
  3. required TransitionType type,
  4. Offset? offset,
  5. Duration animationDuration = const Duration(milliseconds: 300),
})

Implementation

NavigateRoute(this.widget,
    {this.rootNavigator,
    required this.type,
    this.offset,
    this.animationDuration = const Duration(milliseconds: 300)})
    : super(
        pageBuilder: (context, animation, secondaryAnimation) => widget,
        transitionDuration: animationDuration,
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          if (type == TransitionType.scale) {
            return ScaleTransition(
              scale: animation.drive(
                Tween(begin: 0.8, end: 1.0).chain(
                  CurveTween(curve: Curves.ease),
                ),
              ),
              child: child,
            );
          } else if (type == TransitionType.fade) {
            return FadeTransition(
              opacity: animation.drive(
                Tween(begin: 0.0, end: 1.0).chain(
                  CurveTween(curve: Curves.ease),
                ),
              ),
              child: child,
            );
          } else if (type == TransitionType.fadeScale) {
            return ScaleTransition(
              scale: animation.drive(
                Tween(begin: 0.8, end: 1.0).chain(
                  CurveTween(curve: Curves.ease),
                ),
              ),
              child: FadeTransition(
                opacity: animation.drive(
                  Tween(begin: 0.2, end: 1.0).chain(
                    CurveTween(curve: Curves.ease),
                  ),
                ),
                child: child,
              ),
            );
          } else if (type == TransitionType.reveal) {
            final screenSize = MediaQuery.of(context).size;
            Offset center =
                Offset(screenSize.width / 2, screenSize.height / 2);
            double beginRadius = 0.0;
            double endRadius = screenSize.height * 1.5;
            final tween = Tween(begin: beginRadius, end: endRadius);
            final radiusTweenAnimation = animation.drive(tween);
            return ClipPath(
              clipper: CircleClipper(
                  radius: radiusTweenAnimation.value,
                  center: offset ?? center),
              child: child,
            );
          }

          var begin = getTransitionOffset(type);
          var end = Offset.zero;
          var curve = Curves.ease;
          var tween =
              Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
          return SlideTransition(
            position: animation.drive(tween),
            child: child,
          );
        },
        reverseTransitionDuration: const Duration(milliseconds: 100),
      );