flutterdartanimatedcontaineranimationcontroller

Flutter AnimatedContainer vs AnimationController


I can't find the difference between the two, and why you would want to use one above the other.

The way I see it, both of them pretty much does the same thing.

Why and where would you use one above the other?


Solution

  • AnimatedContainer is used for getting things done fast and for simple uses because it uses implicit animations to animate the change in its properties like a change in color or size (width,height) So it makes the animation for you and you don't need to worry or write boilerplate

    However, AnimationController is used when you need more control on the animation you want to create and when the animation is complex in this case you will need to do an explicit animation( i.e. using a controller and animation object explicitly and not implicitly as in case of AnimatedContainer) now I could provide you with an example code but it would be better if you check this series of videos from official flutter team that explains the difference and when to use each one