Contents

Home › Articles

Flutter Animation Widgets: A Practical Introduction

By Priya Shah · Published · 4 min read

Colorful spinning object with motion blur representing animation widgets.
Colorful spinning object with motion blur representing animation widgets. · Foto: FrankyFromGermany / Pixabay

Motion is not decoration. In a well-built Flutter app, animation tells users where they came from, what changed, and what they can do next. The framework gives you a ladder of tools, from one-line implicit widgets to fully orchestrated controllers, and picking the right rung saves you both code and frame budget.

This guide walks through the animation widgets you will actually use day to day: AnimatedContainer, AnimatedOpacity, AnimatedSwitcher, TweenAnimationBuilder, and the explicit trio of AnimationController, Tween, and AnimatedBuilder. You will also get realistic duration ranges, a comparison table, and the performance rules that keep transitions smooth on mid-range Android hardware.

Implicit animations: one line, zero controllers

Implicit animation widgets animate a property change for you. You pass a new value to something like AnimatedContainer or AnimatedOpacity, and the widget interpolates from the old value to the new one over a duration you specify. There is no controller to create, dispose, or tick, which makes them the default choice for simple state changes such as a button growing when pressed or a card fading in.

The catch is that each implicit widget only animates its own properties, and it always starts from the current value rather than a scripted sequence. For UI feedback loops they are ideal; for choreography, they run out of road quickly. Keep durations in the 150-300 ms range for small state changes and 300-500 ms for larger layout shifts, and you will match what users expect from native apps.

Because implicit widgets rebuild internally, they are cheap but not free. If you animate a container inside a long list, the rebuild cost lands on every visible item during the transition. For list-heavy screens, animate the parent or use a repaint boundary, and read How to Size a RecyclerView Adapter for Smooth Lists for the equivalent thinking on the Android side.

  • AnimatedContainer: size, color, padding, border radius, alignment
  • AnimatedOpacity: fade elements in and out without a controller
  • AnimatedPadding and AnimatedAlign: layout shifts that feel physical
  • AnimatedDefaultTextStyle: smooth typography changes
  • AnimatedSwitcher: cross-fade between two child widgets
150Button press250Fade in card350Screen transition800Count-up number400Hero image
Typical animation durations by use case (ms) (milliseconds)

TweenAnimationBuilder: tween without a controller

TweenAnimationBuilder sits between implicit and explicit animation. You give it a Tween (say, from 0.0 to 1.0), a duration, and a builder callback that receives the current value each frame. It handles the controller lifecycle for you, which makes it perfect for one-off animations such as counting a number up, drawing a progress arc, or sliding a custom widget into place.

The builder rebuilds only the subtree it returns, so keep that subtree small. If you find yourself wrapping half the screen, that is a signal to move the animation lower or switch to an explicit controller with a child passed to AnimatedBuilder. A typical count-up animation runs 600-1200 ms; anything longer starts to feel like waiting rather than feedback.

Because TweenAnimationBuilder restarts whenever its tween changes, it pairs well with values driven by state. When that state must survive rotation or backgrounding, handle it deliberately. Handling Configuration Changes in Kotlin Without Losing State covers the same problem on the Android side and the patterns transfer cleanly.

Flutter animation approaches compared
ApproachController neededTypical durationBest forCode cost
AnimatedContainer / AnimatedOpacityNo150-300 msSimple state feedbackVery low
AnimatedSwitcherNo200-400 msSwapping child widgetsLow
TweenAnimationBuilderNo300-1200 msComputed values, custom drawsLow-medium
AnimationController + TweenYes250-500 msSequencing, looping, gesturesMedium-high
AnimatedBuilderYes (shared)Matches controllerRebuilding only affected widgetsMedium
Hero + PageRouteBuilderNo (route-level)300-400 msScreen-to-screen transitionsLow-medium

Explicit animation: AnimationController and AnimatedBuilder

When you need to start, stop, reverse, or chain animations, you need an AnimationController. It lives in a State object, requires a TickerProvider (usually via SingleTickerProviderStateMixin), and must be disposed. In return you get full control: forward(), reverse(), repeat(), and listeners that fire on every tick.

The usual pattern is a controller driving one or more Tweens, with AnimatedBuilder rebuilding only the widgets that depend on the animation value. Pass static widgets through the child parameter so they are built once, not sixty times a second. This single habit is the difference between a transition that holds 60 fps and one that stutters on a two-year-old device.

Curves matter as much as timing. A 300 ms transition with Curves.easeInOut feels intentional; the same duration linear feels mechanical. For screen transitions, 250-400 ms is the sweet spot. Longer than about 500 ms and users start tapping through the animation, which is worse than no animation at all.

  • Create the controller in initState with vsync: this
  • Dispose the controller in dispose, always
  • Drive Tweens from the controller and read values in AnimatedBuilder
  • Pass static subtrees via the child parameter
  • Choose a Curve deliberately, not by default

Choosing the right widget for the job

The decision tree is short. If a single property changes in response to state, use an implicit widget. If you need to compute intermediate values or draw custom shapes, use TweenAnimationBuilder. If you need sequencing, looping, or user-driven control, use an AnimationController. Most screens need the first two; only hero transitions and gesture-driven effects need the third.

A common mistake is reaching for an AnimationController because it feels more professional. The cost is lifecycle code, disposal bugs, and more places to leak a ticker. Start implicit, and graduate only when the requirement genuinely demands it. Your widget tree will stay smaller and your review comments shorter.

The same restraint applies to app-wide style decisions. Animation choices should follow the design language you committed to; Cupertino vs Material Widgets: Which Style Fits Your App? is a useful check before mixing motion idioms from both.

Performance rules that keep motion smooth

Flutter can hit 60 fps on modest hardware, but only if you avoid rebuilding large subtrees per frame. Wrap animated widgets in RepaintBoundary when they sit above complex content, keep AnimatedBuilder scopes tight, and avoid triggering layout during animation where a transform would do. Transform and opacity are the cheapest properties to animate.

Watch your durations against device class. On low-end Android phones, heavy blurs, large shadows, and opacity over full-screen images are the usual suspects for dropped frames. Test on a real mid-range device, not just a simulator, and profile with the performance overlay before you ship. A 200 ms animation that stutters is worse than a 100 ms one that does not.

Finally, respect reduced-motion settings where your app supports them, and never animate content that the user is trying to read. Motion should support the task, not compete with it.

  • Prefer Transform and Opacity over layout-changing properties
  • Keep AnimatedBuilder child subtrees static
  • Use RepaintBoundary around expensive animated regions
  • Profile on mid-range hardware, not only emulators
  • Start with implicit widgets; they cover most UI feedback with a fraction of the code.
  • Use TweenAnimationBuilder when you need interpolated values but not full control.
  • Reserve AnimationController for sequencing, looping, and gesture-driven motion, and always dispose it.
  • Keep small transitions around 150-300 ms and screen transitions under 500 ms, and profile on real mid-range hardware.
Priya Shah · Android and Kotlin author
Covers Kotlin, Jetpack libraries and Android architecture with a hands-on approach. Focuses on migration guides, database work and networking patterns for small teams.

Related articles

↑