Flutter 具有强大而灵活的 动画 支持 — 从简单的隐式动画到完全受控的显式动画。动画通过平滑的过渡和运动增强 UX,Flutter 的小部件系统使其易于理解。
隐式动画(简单方式)
// 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.
隐式动画(、 等)在其属性更改时自动进行动画处理 — 添加动画最简单的方式。
