【发布时间】:2019-08-24 07:57:05
【问题描述】:
我有一个简单的AnimatedWidget,带有一个子小部件。
AnimatedContainer(
duration: Duration(milliseconds: 2000),
curve: Curves.bounceOut,
decoration: BoxDecoration(
color: Colors.purple,
),
child: FlutterLogo(
size: _boxSize,
),
),
_boxSize 的动画如下:
void _startAnimation() => setState(() {
_boxSize *= 1.7;
});
但是,AnimatedContainer 对 child 小部件不起作用。您需要更改 AnimatedContainer 的直接属性才能使动画正常工作。
这符合文档:
The [AnimatedContainer] will automatically animate between the old
and new values of properties when they change using the provided curve
and duration. Properties that are null are not animated.
Its child and descendants are not animated.
AnimatedContainer 的等价物是什么,它也可以为其子级设置动画?
【问题讨论】:
-
您找到解决方案了吗?
标签: dart flutter flutter-animation