【问题标题】:Issue in setting container's height设置容器高度的问题
【发布时间】:2020-04-27 18:41:45
【问题描述】:

我是 Flutter 的新手。我有一个设置容器高度的代码。 在这里请检查,如果条件成立,其设置高度 100 否则 60,我想将 60 设置为其孩子的高度。意味着它应该必须

selectedIndex != null && showExpanded == true ? 100 : (取决于孩子的身高),

这是我的代码...

                    height: selectedIndex != null && showExpanded == true
                        ? 100
                        : 60,
                    duration: Duration(milliseconds: 300),
                    // Provide an optional curve to make the animation feel smoother.
                    curve: Curves.fastOutSlowIn,
                    decoration: BoxDecoration(
                        border:
                            Border.all(width: 1, color: HexColor("#BCE0FD"))),)

【问题讨论】:

    标签: flutter dart flutter-animation


    【解决方案1】:

    如果你想容器匹配它的高度和它的孩子,只需将它的高度字段设置为空。

    height: selectedIndex != null && showExpanded == true
          ? 100
          : null,
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多