SlideTransition is a transition animation for page jumps

(A) To achieve this function, there are five steps, as follows

A, create a PageRouteBuilder B, create a Tween C, add an AnimatedWidget D, and use a CurveTween E to combine the two Tweens

Create a RouteBuilder using the PageRouteBuilder constructor to create a route. PageRouteBuilder. In the process of building, there is a mandatory parameter pageBuilder. The purpose of PageRouteBuilder is to get the page to jump to, and an optional parameter, transitionDuration, is to animate the transition during the jump

The transitionDuration property, which is given a property by default, returns a Widget, as shown below

To implement your own transitions, you implement transitionsBuilder to override the default transitionsBuilder.

B) create a Tween that contains the start and end positions of the animation

Var begin = Offset(0.0, 1.0); Var end = offset.zero; Then initialize Tween and assign it to the optional named parameter var Tween = Tween(begin: begin, end: end);

C, add an AnimatedWidget

There are many components in Flutter that inherit from the AnimatedWidget. Here we use SlideTransition. There is a required position parameter of type Animation that contains values that change during the Animation

Animation, the second argument to the transitionDuration method, is of type animation and, combined with the created tween, generates the type required for position

D. Use a CurveTween to complete the animation according to certain curve algorithms during the animation process. We use Curves, which include a number of curve algorithms that are already defined.

We use var curve = Curves. Ease and then call tween. chain as the parent of Tween and pass it in as a parameter

E, combine these two Tweens

The core code is shown below

Add effect picture 1, pop up the second page 2 from the bottom, pop up the second page 3 from the right, pop up the second page from the bottom right