Reputation: 984
How do I add a duration to the CupertinoPageRoute? Currently it slides too quick and the effect is not very good.
Navigator.push(
context,
CupertinoPageRoute<Null>(
builder: (context) => View(),
),
);
Upvotes: 1
Views: 1156
Reputation: 29
My solution was not via CupertinoPageRoute, but maybe it can help.
Create a Route that you can customise:
Route yourCustomRoute() {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => YourView(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var begin = Offset(-0.1, -0.1); //start position from top and left corner f.e.
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,
);
},
transitionDuration: Duration(seconds: 10) //any duration you want
);
}
Add your route to Navigator:
Navigator.of(context).push(yourCustomRoute());
Read about routing between two pages here: https://flutter.dev/docs/cookbook/animation/page-route-animation
Upvotes: 1