Flutter har kraftfuld, fleksibel animation-understøttelse — fra simple implicit animationer til fuldt kontrollerede explicit animationer. Animationer forbedrer UX med glatte overgange og bevægelse, og Flutters widget-baserede system gør dem tilgængelige.
Implicit animationer (den nemme måde)
// implicitly-animated widgets animate AUTOMATICALLY when their properties change
AnimatedContainer(
duration: Duration(milliseconds: 300),
width: _expanded ? 200 : 100, // change width → it animates smoothly
height: _expanded ? 200 : 100,
color: _expanded ? Colors.blue : Colors.red,
)
// just change the value (with setState) → Flutter animates the transition
// others: AnimatedOpacity, AnimatedPadding, AnimatedPositioned, etc.
Implicit animationer (, , osv.) animerer automatisk når deres egenskaber ændres — den nemmeste måde at tilføje animation.
