如何匹配其他小工具中最高的行小工具的高度

时间:2019-09-05 12:31:58

标签: flutter flutter-layout

我已经定义了行列小部件,但是无法匹配行中定义的其他小部件的高度

我尝试使用Expand,Innernsic Height,width,Contrained框并在每列内部定义容器。

预期结果应与父/其他行小部件的高度匹配[在此处输入图像描述] [1]

Widget columnOne(String t1, String t2) {
 return ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8)),
child: Container(
  color: Colors.white,
  child: Column(
    mainAxisSize: MainAxisSize.max,
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: <Widget>[
      Container(
        color: Colors.white,
        child: Padding(
          padding:
          EdgeInsets.fromLTRB(10, 10, 10, 10),
          child: Align(
            alignment: Alignment.center,
            child: Text(t1,
                style: TextStyle(
                    fontSize: 30,
                    color: Colors.black,
                    backgroundColor: Colors.white,
                    fontFamily: 'FJ',fontWeight: FontWeight.bold
                )),
          )
        ),
      ),
      IntrinsicHeight(
        child: ConstrainedBox(
          constraints: const BoxConstraints(minWidth: double.infinity),
          child: Container(
              color: Colors.red,
              child: Padding(
                  padding: EdgeInsets.all(10),
                  child: Align(
                    alignment: Alignment.center,
                    child: Text(t2 ,
                        textAlign: TextAlign.center,
                        textWidthBasis: TextWidthBasis.parent,
                        style: TextStyle(
                          fontSize: 16,
                          color: Colors.black,
                          backgroundColor: Colors.red,
                        )),
                  ))),
        )
      )


    ],
  ),
),
 );

}

https://i.stack.imgur.com/HfYOl.png 当前结果如果我更改文本/溢出文本

https://i.stack.imgur.com/t9MTK.png 预期

1 个答案:

答案 0 :(得分:1)

从设计的角度来看,卡的底部只能是一两行。 在这种情况下,不依赖于自动高度,而是使用固定值会更容易。

enter image description here

<app-countdown></app-countdown>