Implicit vs explicit animations: AnimatedContainer or AnimationController?
Knowledge of Flutter's implicit versus explicit animation paradigms. Implicit widgets auto-animate property changes on rebuild; explicit controllers manage playback manually. Red flag: saying explicit is always superior or that implicit animations cannot stop.
What's really being asked
This question probes whether you understand the architectural split between Flutter's declarative implicit animation widgets and its imperative explicit animation APIs. A senior candidate should know that implicit widgets hide the AnimationController lifecycle while explicit controllers expose it, and you should be able to pick the right tool based on complexity and interaction needs rather than defaulting to the most powerful option.
The full answer
First, define implicit animations as widgets like AnimatedContainer, AnimatedOpacity, and AnimatedPositioned that automatically tween to new property values whenever the widget rebuilds with different parameters. They manage their own internal AnimationController, curve, and duration, so you only declare the target state. Second, define explicit animations as those driven by an AnimationController that you instantiate, start, stop, and dispose manually, giving you precise control over duration, reverse playback, and animation status listeners. Third, explain the decision boundary: choose AnimatedContainer when you have a simple property change triggered by state, such as color, size, padding, or border radius transitions, because it removes boilerplate and avoids lifecycle bugs. Choose AnimationController when you need interactive control, chained or staggered sequences, physics-based motion, or when the animation must run outside of a simple rebuild cycle. Fourth, mention that implicit animations can be customized with duration and curve parameters, and that you can interrupt them mid-flight by changing the target value again, which is a common misconception.
The mistakes people make
A major red flag is claiming that AnimationController is always the correct choice because it is more powerful; this signals unfamiliarity with Flutter's declarative philosophy and leads to unnecessary StatefulWidget boilerplate. Another mistake is saying that AnimatedContainer requires you to manage an AnimationController; it does not, because it is an implicitly animated widget. Candidates sometimes also argue that implicit animations cannot be interrupted or curved, which is false since both duration and curve are constructor parameters. Finally, suggesting explicit controllers for every UI transition shows poor judgment about code simplicity and maintainability.
What usually comes next
The interviewer may ask how you would stagger multiple property changes, which pushes toward explicit controllers or TweenSequence. They might ask about performance differences between many implicit widgets versus a single explicit controller, where the answer is that a single controller is usually more efficient for complex coordinated motion. Another follow-up is how to interrupt an implicit animation and start a new one from the current intermediate value, which requires switching to an explicit controller or using a package. They could also ask about disposing implicit widgets, testing the knowledge that you do not dispose their internal controllers because the widget owns them.
A concrete example
Imagine a settings card that expands when tapped. If you only need to animate height and background color, AnimatedContainer is ideal because you change the height variable in setState and the widget handles the tween. If you need the card to expand while simultaneously rotating an icon 180 degrees, bouncing at the end, and allowing the user to pause the motion with a long-press, you need an AnimationController with multiple Tweens and a GestureDetector because implicit widgets cannot synchronize complex multi-step interactive choreography.
Interview question
You need to animate a container's padding and border radius whenever a user toggles a setting. Which approach minimizes boilerplate while correctly handling the animation lifecycle?
- a.Instantiate an AnimationController in a StatefulWidget, define separate Tweens for padding and border radius, and manually start the animation in setState.
- b.Wrap the child in an AnimatedPadding widget and update its values in setState, relying on the framework to animate both padding and border radius automatically.
- c.Use an AnimationController with AnimatedBuilder because implicit widgets cannot be curved or interrupted mid-flight.
- d.Use an AnimatedContainer, pass the new padding and decoration values on rebuild, and configure the duration and curve through its constructor.Correct
Why? this is the answer
AnimatedContainer is an implicitly animated widget that automatically tweens to new property values on rebuild while managing its own internal AnimationController, making it the simplest choice for state-driven padding and radius changes. Option A is tempting but wrong because using an explicit controller for a simple property transition introduces unnecessary StatefulWidget boilerplate and contradicts Flutter's declarative philosophy.
Just read this? Test yourself on what you have been reading.
Read the original → docs.flutter.dev
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on flutter — each one lists the topics its interview covers.
See open roles