Let’s quickly create an example similar to one in the first article: No animation controller, no tween, no animation and yet it animates to the final value! So, why did we not use this approach earlier?īecause, internally, the class uses the same mechanism for creating a Tween for size or color that we used in the first example.įirst, we simply use a ImplicitlyAnimatedWidget, here AnimatedContainer, and on button click, we change the values we want to. Note that the animation duration is specified by the user. Similarly, if color or any other property is changed, it will animate to the final property instead of jumping to the final value. Instead, it will gradually change just like it did with our animation code!
When we change the value of the box from, say, 100.0 to 300.0, it will not jump to the final size directly.
If we switch the Container used in the example with an AnimatedContainer, we do not need all of the animation code we discussed earlier. Here is where ImplicitlyAnimatedWidgets step in. What if we directly changed the box size from, say, 100.0 to 300.0 without any kind of Tween or AnimationController? It would just jump from the initial size to the final size. To increase the size of the box, we set an initial and final size and then used a Tween to grow the box size gradually. In this example, we used an AnimationController and a Tween to change the size and color of the box. So, let’s first start where left off from the last article: This definition of implicitly animated widgets can sound a bit confusing. Implicitly Animated Widgets are widgets that automatically animate changes in themselves. for implicitly animated widgets, we can effectively say that the code is implicit, meaning it is in-built and does not have to be manually written. When we call something ‘implicit’, we mean a quality is inherent in something.
Turning, scaling and translating objects.
This article builds heavily on top of it. I would highly recommend reading my previous article on the basics of Flutter animations. In a stroke of irony, we will begin advanced Flutter animations with the animations that require the least amount of code. Even the most complex animations are just variants and combinations of the same type of animation method. However, the reason we went with the Ticker + Tween + Controller method in our previous article is that it forms the base of all Flutter animations. In this one, we will delve much deeper, covering implicitly animated widgets, advanced animations and best practices to follow when creating Flutter animations.Īs you will see in this article, there are easier ways to create Flutter animations. Welcome to the second article in our Flutter animation series! In our first article, we touched upon the absolute basics of Flutter animations.