如何将曲线(例如Curves.easeIn)添加到AnimatedList的动画中?
AnimatedList(
key: _animList,
initialItemCount: _myList.length,
itemBuilder: (context, index, animation) {
return SlideTransition(
position: animation.drive(Tween(begin: Offset(1, 0), end: Offset(0, 0))), <-- curve?
child: Container(color: Colors.red, height: 100, width: 100)
);
}
)
您应该在Tween上调用chain方法。 chain方法采用CurveTween,而CurveTween采用curve
尝试一下
AnimatedList(
key: _animList,
initialItemCount: _myList.length,
itemBuilder: (context, index, animation) {
return SlideTransition(
position: animation.drive(
Tween(begin: Offset(1, 0), end: Offset(0, 0))
.chain(CurveTween(curve: Curves.bounceIn))),
child: Container(color: Colors.red, height: 100, width: 100));
});