IntrinsicHeight 保持row子组件高度
当我们使用行(row)的时候,子组件常常因为高度的不同,导致各个子组件里面的内容不能对齐。这个时候我们可以使用IntrinsicHeight来保持row中各个子组件高度一致,从而便于纵向居中对齐。
参考下面的代码:
IntrinsicHeight(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(color: Colors.blue, width: 100.0),
Container(color: Colors.red, width: 50.0,height: 50.0,),
Container(color: Colors.yellow, width: 150.0),
],
),
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
上次更新: 2022/12/11, 02:32:13