如何在动画中制作动画

时间:2020-04-26 16:54:29

标签: flutter flutter-animation

我正在尝试将徽标向右滑动,然后又从左侧滑出 enter image description here 我试过了,但徽标反弹了

void initState() {
super.initState();
_controller = AnimationController(
 // duration: const Duration(seconds: 90),
  vsync: this,
)..repeat(reverse: false);
_offsetAnimation = Tween<Offset>(
  begin: Offset.zero,
  end: const Offset(7.1, 7.0),
).animate(CurvedAnimation(
  parent: _controller,
  curve: Curves.easeOutQuint,
));

}

1 个答案:

答案 0 :(得分:0)

您可以尝试使用以下代码将徽标向右滑动,然后再从左侧滑动徽标,

void initState() {
  super.initState();
  _controller = AnimationController(
  duration: const Duration(seconds: 2),
    vsync: this,
  )..repeat(reverse: true);
  _offsetAnimation = Tween<Offset>(
    begin: Offset(-1.0,0.0),  // You can change starting position as per your require.
    end: const Offset(1.0, 0.0),  // You can change ending position as per your require.
  ).animate(CurvedAnimation(
    parent: _controller,
    curve: Curves.linear,  // You can change animation curve per your require.
  ));
}

(请参考Curves class以选择其他曲线)。