【发布时间】:2019-04-01 08:41:20
【问题描述】:
我想为容器的高度设置动画
我想做的是:
class _AddVehicleState extends State<AddVehicle>
with SingleTickerProviderStateMixin {
AnimationController _otherFieldsAnimationController;
Animation<double> _heightAnimation;
override
void initState() {
_otherFieldsAnimationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 3000),
);
_heightAnimation = new Tween<double>(begin: 400.0, end: 20.0)
.animate(_otherFieldsAnimationController);
_otherFieldsAnimationController.forward();
}
@override
Widget build(BuildContext context) {
return new WillPopScope(
onWillPop: _onWillPop,
child: new Scaffold(body: Builder(builder: (scaffoldContext1) {
scaffoldContext = scaffoldContext1;
return Stack(
children: <Widget>[
new Container(
decoration: getGradientBackground(),
child: ListView(
children: <Widget>[
Container(
color: Colors.white70,
height: _heightAnimation.value,
child: Center(
child: Text('HEY'),
));
.
.
.
.
.
如您所见,容器包含 Animation 的高度。
此页面上的所有其他动画都可以正常运行,但此容器没有动画。
有什么特别的原因吗?还是我错过了什么?
【问题讨论】: