我希望使用AnimatedContainer的transform属性为容器的比例设置动画;然而,规模没有被过渡,直接从开始跳到结束。
代码片段:
var container = new AnimatedContainer(
duration: const Duration(milliseconds: 200),
width: 50.0,
height: 50.0,
// selected is a bool that will be toggled
transform: selected ? new Matrix4.identity() : new Matrix4.identity().scaled(0.2,0.2),
decoration: new BoxDecoration(
shape: BoxShape.circle,
backgroundColor: Colors.blue[500],
),
child: new Center(
child: new Icon(
Icons.check,
color: Colors.white,
),
)
);
Run Code Online (Sandbox Code Playgroud)
关于发生了什么的任何见解?
恐怕transform这是我们不设置动画的属性之一(child是另一个属性)。如果您想对比例进行动画处理,可以使用 ScaleTransition。
ScaleTransition:https://docs.flutter.io/flutter/widgets/ScaleTransition-class.html
Matrix lerp 的错误:https ://github.com/flutter/flutter/issues/443
| 归档时间: |
|
| 查看次数: |
7993 次 |
| 最近记录: |