繁体   English   中英

如何在 flutter 上添加 animation 以获取动态项目列表?

[英]How can I add animation on flutter for dynamic list of items?

我正在为一款游戏构建一个应用程序,您可以在其中跟踪装甲的升级水平。 每个级别都有一些升级所需的材料。 前任:

Level 1 - 10 of Materials A
Level 2 - 5 of Materials B
Level 3 - 10 of Materials C

我有一个页面,其中有一个星级小部件,当用户更改时,它会更新我的盔甲的等级属性。 通过使用提供程序,我的材料列表会更新为仅显示剩余的材料。 因此,如果我的盔甲处于 1 级,它会显示:

Level 2 - 5 Materials B
Level 3 - 10 Materials C

当我的盔甲处于 2 级时,它会显示:

Level 3 - 10 Materials C

我想要做的是在该材料离开屏幕时添加一个 animation 而不是仅仅隐藏它。

这是我必须显示包含信息的行列表的设置

        Column(
            children: armor.listOfUpgradeMaterials.map((material) {
          return Container(
            child: Column(children: [
                MaterialByLevelRow(material),
              Divider(
                color: Theme.of(context).accentColor.withOpacity(0.5),
                height: 0,
              ),
            ]),
          );
        }).toList())

现在在我的MaterialByLevelRow小部件中,我有一个AnimatedContainer

 height: shouldDisplayRow ? 40 : 0,

那是最好的选择吗? 这样,屏幕上会出现几行,但高度为零,这不是一个坏习惯吗?

如果我想通过改变高度添加滑入式 animation 怎么办,这可能吗?

尝试使用AnimatedList()小部件。

有关更多帮助,请参阅此博客文章: https://medium.com/flutter-community/updating-data-in-an-animatedlist-in-flutter-9dbfb136e515

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM