Changing transition of screen using Auto Route flutter

1.3k views Asked by At

I am using auto route in my flutter app. I need different page transitions for single page, for example if you are opening screen A from screen B it should open from rightside(Screen A should have transition Transitions.slideRight) and if you are opening screen A from Screen C it should open from left side. This mean that I have to change that transition programmatically in runtime, but don't know how to do that because flutter autoroute works with generated routes, and I am not sure that I can write some conditions for that. Please give me some solutions to fix this if it is possible.

1

There are 1 answers

0
Jean Cuervo On

in your router file, you can use CustomRoute instead of AutoRoute:

    CustomRoute(
        page: HomePage,
        transitionsBuilder: TransitionsBuilders.slideRight),

you can see more info here: https://pub.dev/documentation/auto_route/latest/#custom-route-transitions