2

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()));
Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
sagar dhiman
  • 293
  • 2
  • 11

1 Answers1

2

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
Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
  • Thank 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. – sagar dhiman May 08 '19 at 12:12