Your experience on this site will be improved by allowing cookies
Routes are simply Pages in Flutter applications. An application often needs to move from one page to another. But to make these transitions smoother, Animations can be used. These animations can be used to curve or tween the Animation object of the PageRouteBuilder class to alter the transition animation. We will discuss them in detail here.
Let’s just build a simple app to better understand the concept. Follow the below steps to do so:
Let’s discuss each step in detail:
By using the PageRouteBuilder create two routes with the first route as the “Homepage” with a button “Goto page 2” and the second route with just an empty page named “Page 2”, using the below code:
|
You can build a tween of an animation object by using the below code :
|
The AnimatedWidget has the property of its state once the animation value changes. You can create one like below:
|
Use the below code to create a CurveTween:
|
Use the chain() method to combine two tweens as shown below:
|
Now use the animation.drive() method to create an Animation object of the combined tweens as shown below:
|
Complete Source Code:
|
Output:
0 comments