Magic of Mind Mapping in Leadership

Mind mapping is a powerful tool we can use as leaders to balance our logical thinking processes with expansive, innovative thinking about how to approach our work. We can also better understand and…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Everything you need to know about Flutter page route transition

We know how easy it is to navigate from one route to another in Flutter. We just need to do push and pop.

To push:

To pop:

That’s it. BUT… It’s very boring, there is no animation at all 😦 .

We know that Navigator.push takes two arguments (BuildContext context, Route<T> route). We can create our own custom page route with some transition animation. Let’s start with something simple like a slide transition.

We will extend the PageRouteBuilder and define the transitionsBuilder which will return SlideTransition widget. The SlideTransition widget takes the position of type Animation<Offset>. We will use Tween<Offset> to give begin and end offset.

We can now use SlideRightRoute instead of MaterialPageRoute like this.

The result is…

Pretty easy, isn’t it? You can change the direction of the slide transition by changing the offset.

Scale Transition animates the scale of a transformed widget. You can also change how the animation comes in by changing the curves of CurvedAnimation. In the below example I have used Curves.fastOutSlowIn.

The result is…

Rotation transition animates the rotation of a widget. You can also provide transitionDuration to your PageRouteBuilder.

The result is…

The result is…

The result is…

Great!! We have seen all the basic transitions.

Now let’s do something more advance. What if we want to animate both the routes. The entering route(new page) and the exit route(old page). We can use the stack transition animations and apply it to both the routes. one example of this could be the slide in the new route and slide out the old route. This is my favourite transition animation ❤️. Let’s see how we can do it.

And use it like this.

And the result is…

We can also combine more than one transition to create something awesome like scale and rotate at the same time. First, there is a ScaleTransition, child of it is RotationTransition and it’s child is the page.

And the result is…

Add a comment

Related posts:

PREDIKSI SKOR BOLA MALAM INI ANTARA KROASIA Vs MAROKO 17 DESEMBER 2022

Prediksi Skor Bola Malam Ini Antara Kroasia Vs Maroko 17 Desember 2022 adalah situs menebak angka pertandingan sepak bola online yang ditayangkan secara langsung malam ini. Perebutan juara 3 Piala Dunia 2022 Qatar akan berlangsung pada 17…

Privacy Month

In the month of January Mozilla India started a month long campaign to spread awareness about privacy, and shared various tips to stay safe online. Tip 1: While registering for a website use email…

De chorro en chorro

Y voy haciendo equilibrio, tratando de no caerme. Y voy pasando el miedo de izquierda a derecha, tratando de no caerme. Y me balanceo en la vida, un pie adelante y otro atrás, un paso adelante y…