How to go to second page with page transition in flutter?
702
Try by adding Duration()
like below code:
Navigator.push(context, PageTransition(type: PageTransitionType.scale,child:Registration(),duration: Duration(seconds: 5)));
Use Below Dependency:
dependencies:
page_transition: '^1.0.9'
You can also use other animations as below.
Navigator.push(context, PageTransition(type: PageTransitionType.fade, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.leftToRight, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.upToDown, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.downToUp, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.scale, alignment: Alignment.bottomCenter, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.size, alignment: Alignment.bottomCenter, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.rotate, duration: Duration(second: 1), child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeftWithFade, child: DetailScreen()));
Navigator.push(context, PageTransition(type: PageTransitionType.leftToRightWithFade, child: DetailScreen()));
Types of transitions
- fade
- rightToLeft
- leftToRight
- upToDown
- downToUp
- scale (with alignment)
- rotate (with alignment)
- size (with alignment)
- rightToLeftWithFade,
- leftToRightWithFade
Author by
sagar dhiman
Updated on December 11, 2022Comments
-
sagar dhiman over 1 year
I have used the transition.dart library and also made a transition dart file but I am always getting transition when I am coming back from the second page to the first page. But I need transition when I am going to the second page.
My code is:
Navigator.push(context,PageTransition(type: PageTransitionType.scale,child:Calculator()));
-
sagar dhiman almost 5 yearsThank you so much #Darshan Kunjadiya. After adding the duration, it's working properly. please ping me on skype: sagardhiman5_1 . It would be a pleasure to connect you.