小编Ans*_*war的帖子

如何使 AnimatedContainer 在初始小部件构建后更改高度,而不是在单击按钮时更改高度

                Expanded(
                  flex: 1,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 3.0, right: 1),
                    child: AnimatedContainer(
                      duration: Duration(seconds: 1),
                      height: voteCountList[0],
                      decoration: BoxDecoration(
                        color: ColorChooser.graphColors[int.parse(optionsList[0]['color'])],
                        borderRadius: BorderRadius.all(Radius.circular(2))
                      ),
                    ),
                  ),
                ),
Run Code Online (Sandbox Code Playgroud)

正如我的代码片段中所示,动画容器的高度是 voteCountList[0],如果更新值,则效果很好。然而,当小部件最初构建时,没有动画,容器的高度立即 = voteCountList[0]。我想实现 AnimatedContainer,以便看到容器的高度从 0 到 voteCountList[0] 进行动画处理。这个高度需要在构建时进行动画处理。

height duration flutter animatedcontainer

2
推荐指数
1
解决办法
2988
查看次数

标签 统计

animatedcontainer ×1

duration ×1

flutter ×1

height ×1