Implicit animations
Animated*
elements draw like their plain counterparts (
Container
,
Opacity
,
Positioned
…), but
they do not apply a new parameter value at once — they ease towards it
over
duration:
along the
curve:
. There is nothing to start: it is enough for the value to depend on state (
width:{open ? 240 : 120}
) — the state changes, the animation runs.
When to use them: expanding a block, highlighting a selection, appearing and disappearing, moving inside a
Stack
. For motion over time with no event (a ticker, a pulse) use
`Animated loop:true`
; for a film driven by a clock,
`*Scene`
.
Common to all
| Parameter | Type | Default | Description |
|---|---|---|---|
duration
|
Duration |
300ms
|
Transition length:
300ms
,
1s
|
curve
|
string |
linear
|
Curve:
linear
,
easeIn
,
easeOut
,
easeInOut
,
easeOutCubic
,
easeOutBack
,
fastOutSlowIn
,
bounceOut
,
elasticOut
and other Flutter curve names
|
delay
|
Duration | — |
Pause before the start. Available on
AnimatedContainer
,
AnimatedOpacity
,
AnimatedPositioned
,
AnimatedSize
|
-
delay:postpones the start without stretching the motion itself: the whole run takesdelay + duration, andcurve:still applies inside it. This is how you make a "wave" — the same motion on neighbours with different delays. - Reduced motion. When the system has "reduce motion" turned on, both the app and the site set the final value at once, with no transition.
- The first value, when the element appears, is not animated — only a change is.
AnimatedContainer
A
Container
whose colour, size, padding, decoration and constraints change smoothly.
Type:
single-child
@open:false
InkWell onTap:{open = !open}
AnimatedContainer duration:300ms curve:easeOutCubic width:{open ? 240 : 120} height:64 color:{open ? 0xFF4F46E5 : 0xFF94A3B8}
Text "Tap me"
| Parameter | Type | Default | Description |
|---|---|---|---|
duration
|
Duration |
300ms
|
Duration |
curve
|
string |
linear
|
Curve |
delay
|
Duration | — | Pause before the start |
color
|
color | — |
Fill. Do not set it together with
#decoration
— then the colour goes into
#decoration color:
|
width
|
double | — | Width |
height
|
double | — | Height |
#padding
|
EdgeInsets | — |
Inner padding:
#padding all 16
|
#margin
|
EdgeInsets | — | Outer margin |
#decoration
|
Decoration | — |
Decoration: colour,
#borderRadius
,
#border
, shadows — as on
DecoratedBox
|
alignment
|
alignment | — |
Where the child sits inside:
center
,
topLeft
, …
|
#constraints
|
BoxConstraints | — |
Size constraints:
#constraints minWidth:100 maxWidth:300
|
clipBehavior
|
string |
none
|
Clipping to the decoration:
none
,
hardEdge
,
antiAlias
,
antiAliasWithSaveLayer
|
@on:false
Column spacing:12
FilledButton onPressed:{on = !on}
Text "Toggle"
AnimatedContainer duration:400ms curve:easeOutCubic width:{on ? 260 : 140} height:72 alignment:center
#decoration color:{on ? 0xFF4F46E5 : 0xFFE2E8F0}
#borderRadius circular {on ? 36 : 8}
#padding all {on ? 16 : 8}
Text {on ? "On" : "Off"}
#style color:{on ? 0xFFFFFFFF : 0xFF0F172A}
AnimatedDecoratedBox
A DecoratedBox whose decoration changes smoothly: colours, border, corner radius, shadows.
Type:
single-child
@selected:false
InkWell onTap:{selected = !selected}
AnimatedDecoratedBox duration:200ms
#decoration color:{selected ? 0xFF4F46E5 : 0xFFF1F5F9}
#borderRadius circular 12
Padding
#padding all 16
Text "Option"
| Parameter | Type | Default | Description |
|---|---|---|---|
#decoration
|
Decoration | empty | Decoration, as on DecoratedBox |
duration
|
Duration |
300ms
|
Duration |
curve
|
string |
easeInOut
|
Curve — the only element of the family whose default is not
linear
|
AnimatedOpacity
Fades the child in and out.
Type:
single-child
@visible:true
AnimatedOpacity opacity:{visible ? 1 : 0} duration:250ms curve:easeOut
Text "Saved"
| Parameter | Type | Default | Description |
|---|---|---|---|
opacity
|
double | 1.0 | Opacity from 0 (invisible) to 1 |
duration
|
Duration |
300ms
|
Duration |
curve
|
string |
linear
|
Curve |
delay
|
Duration | — | Pause before the start |
At
opacity:0
the child is invisible, but it still takes up space and still receives taps. To stop the taps, wrap it in
IgnorePointer
with the same condition.
AnimatedPositioned
A
Positioned
whose coordinates and size change smoothly. It must be a
direct child of a
Stack
— just like
Positioned
.
Type:
single-child
@right:false
SizedBox width:300 height:80
Stack
AnimatedPositioned duration:300ms curve:easeOutCubic left:{right ? 240 : 0} top:10 width:60 height:60
ColoredBox color:0xFFDC2626
| Parameter | Type | Default | Description |
|---|---|---|---|
left
|
double | — |
Distance from the left edge of the
Stack
|
top
|
double | — | Distance from the top edge |
right
|
double | — | Distance from the right edge |
bottom
|
double | — | Distance from the bottom edge |
width
|
double | — | Width |
height
|
double | — | Height |
duration
|
Duration |
300ms
|
Duration |
curve
|
string |
linear
|
Curve |
delay
|
Duration | — | Pause before the start |
AnimatedSize
Smoothly adjusts its own size to the size of its child: an expanding block, an accordion, text that is sometimes shorter, sometimes longer.
Type:
single-child
@expanded:false
Column
InkWell onTap:{expanded = !expanded}
Text "More"
AnimatedSize duration:250ms curve:easeOutCubic alignment:topLeft
Text {expanded ? "A long description that opens in full when you tap the heading." : "In short"}
| Parameter | Type | Default | Description |
|---|---|---|---|
duration
|
Duration |
300ms
|
Duration |
curve
|
string |
linear
|
Curve |
delay
|
Duration | — | Pause before the start |
alignment
|
alignment |
center
|
Where the child sits while the box has not yet caught up with its size |
clipBehavior
|
string |
hardEdge
|
Clipping of content that does not fit the current size;
none
— no clipping
|
AnimatedCrossFade
Smoothly replaces one child with another: the first fades out, the second fades in. There are two children, and they are named by
id:
—
id:first
and
id:second
; a child without such an
id
is not shown.
Type:
multi-child
@done:false
AnimatedCrossFade duration:300ms crossFadeState:{done ? "showSecond" : "showFirst"}
Text id:first "Loading…"
Text id:second "Done"
| Parameter | Type | Default | Description |
|---|---|---|---|
crossFadeState
|
string |
showFirst
|
Which one to show:
showFirst
or
showSecond
; any other value means
showFirst
|
duration
|
Duration |
300ms
|
Duration |
alignment
|
alignment |
topCenter
|
How the children are aligned relative to each other |
firstCurve
|
string |
linear
|
Curve for the first child |
secondCurve
|
string |
linear
|
Curve for the second child |
In the app the box also smoothly changes its size from one child to the other.
@second:false
Column spacing:12
FilledButton onPressed:{second = !second}
Text "Switch"
AnimatedCrossFade duration:400ms crossFadeState:{second ? "showSecond" : "showFirst"} alignment:center firstCurve:easeIn secondCurve:easeOut
ColoredBox id:first color:0xFF4F46E5
SizedBox width:160 height:80
Center
Text "First"
#style color:0xFFFFFFFF
ColoredBox id:second color:0xFF059669
SizedBox width:160 height:80
Center
Text "Second"
#style color:0xFFFFFFFF
AnimatedSwitcher
Animates the
replacement
of its child: the old one fades out, the new one fades in. Like Flutter's
AnimatedSwitcher
, it treats a child as new only when the element itself has changed (its type or key). A change of text or colour on the same element is an update, not a replacement, and is not animated. The element has one child: the analyzer marks a second child as
dropped_child
.
For a smooth switch between two variants, AnimatedCrossFade is more reliable — it works the same in the app and on the site.
Type:
single-child
AnimatedSwitcher duration:250ms switchInCurve:easeOut switchOutCurve:easeIn
Icon check
| Parameter | Type | Default | Description |
|---|---|---|---|
duration
|
Duration |
300ms
|
Duration |
switchInCurve
|
string |
linear
|
Curve for the new child coming in |
switchOutCurve
|
string |
linear
|
Curve for the old child going out |
Differences between the app and the site
On the site these elements become CSS transitions (
transition
) or a small script.
-
The default curve differs.
Without
curve:the app moves alonglinear(AnimatedDecoratedBoxalongeaseInOut), while the site uses the CSSease. Setcurve:explicitly if the motion has to match. On the sitebounce*,elastic*andeaseInOutCubicEmphasizedare replaced withease. -
AnimatedContainer,AnimatedDecoratedBox,AnimatedOpacity,AnimatedPositioned— a transition with the sameduration,curve,delay. -
AnimatedSizeon the site animates only the height ; the width is taken from the parent. -
AnimatedCrossFade— both children are stacked on top of each other, one is visible, the transition is by opacity, with each child's own curve. The box is as large as the larger child, and its size is not animated. -
AnimatedSwitcheron the site does not animate the replacement : the child only fades in once when the page loads (duration,switchInCurve), and after that it changes at once;switchOutCurveis ignored. Of several children withif:, only the first one reaches the page.
Bad practices
Animation without a changing value
// BAD — the value is constant, there is nothing to animate: the element just sits there
AnimatedOpacity opacity:0.5 duration:300ms
Text "Hello"
// GOOD — the value depends on state, a change of state starts the transition
@shown:false
AnimatedOpacity opacity:{shown ? 1 : 0} duration:300ms curve:easeOut
Text "Hello"
See also
- Animated and Ticker — a value over time: a counter, a loop, a timer
- Animation — smooth scale and opacity in one element
-
Transitions and Hero
—
*Transitionwithout animation and a flight between screens - Container , DecoratedBox , Opacity , Positioned — the static counterparts
-
Switcher
— picking a child by
idwithout animation