kalismeras61 / flutter_page_transition

This is Flutter Page Transition Package
BSD 2-Clause "Simplified" License
471 stars 56 forks source link

How to use with transitionBuilder #81

Closed shellking4 closed 1 year ago

shellking4 commented 1 year ago

I want to do something like this

Navigator.pushAndRemoveUntil(
      context,
      PageRouteBuilder(
        pageBuilder: (context, animation, secondaryAnimation) => AuthorScreen(),
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          return PageTransition(
            child: child, 
            type: PageTransitionType.leftToRightWithFade
          )
        },
        transitionDuration: Duration(milliseconds: 500), // Adjust as per your preference
      ),
      (route) => false,
    );

But there is an error saying

The return type 'PageTransition<dynamic>' isn't a 'Widget', as required by the closure's context.

How can I fix this please ?

shellking4 commented 1 year ago

I found a way

Navigator.pushAndRemoveUntil(
      context,
      PageTransition(
        type: PageTransitionType.topToBottom,
        child: AuthorScreen(),
        duration: Duration(milliseconds: 500)
      ),
      (route) => false,
    );

I'm going to close this issue now then