【问题标题】:Flutter SlideTransition with AnimatedListFlutter SlideTransition 与 AnimatedList
【发布时间】:2020-10-02 22:18:26
【问题描述】:

Widget of the Week video 中,他们显示了为这样的项目设置动画的代码:

AnimatedList(
  initialItemCount: _myItems.length,
  itemBuilder: (context, index, animation) {
    return SlideTransition(
      position: animation.drive(MyTween()),
      child: ...
    );
  }
)

我不知道如何配置 MyTween() 以在屏幕上显示孩子开始,然后稍后滑出屏幕。

我终于找到了答案,所以我在下面分享它。

【问题讨论】:

    标签: flutter dart flutter-animatedlist


    【解决方案1】:

    你可以使用

    SlideTransition(
      position: animation.drive(myTween),
      child: Card(...),
    )
    

    myTween 在哪里

    final myTween = Tween<Offset>(
      begin: const Offset(-1.0, 0.0),
      end: Offset.zero,
    );
    

    感谢this page 的帮助。另请参阅我的更一般的答案here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-01
      • 2021-05-17
      • 2020-06-19
      • 2021-11-10
      • 2021-10-28
      • 1970-01-01
      • 2018-04-21
      • 2020-07-02
      相关资源
      最近更新 更多