【问题标题】:How to make animation in flutter如何在颤动中制作动画
【发布时间】:2020-04-26 16:54:29
【问题描述】:

我正在尝试将徽标向右滑动,然后再次从左侧滑动 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,
));

}

【问题讨论】:

    标签: flutter flutter-animation


    【解决方案1】:

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

    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选择其他曲线)。

    【讨论】:

      猜你喜欢
      • 2020-06-17
      • 2020-01-14
      • 2019-09-08
      • 2021-05-30
      • 2021-06-23
      • 1970-01-01
      • 2020-09-01
      • 2019-02-19
      • 1970-01-01
      相关资源
      最近更新 更多