如何在flutter中制作动画

问题描述 投票:0回答:1

我正试图将标志向右滑动,然后再从左手边滑过来。请在此输入图片描述我试过了,但它弹回了标志。

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,
));

}

flutter flutter-animation
1个回答
0
投票

你可以试试下面的代码,把logo滑到右边,然后再从左边滑过来。

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.
  ));
}

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

© www.soinside.com 2019 - 2024. All rights reserved.