Hus*_*ain 5 flutter flutter-layout
问题的图像,显示为彩色矩形
我希望 Column 的第一个孩子是灵活的,第二个孩子占据整个剩余空间。显然,这是行不通的。
我现在知道这是预期的行为。我希望有一个解决方法。
我尝试在第一个子项上使用 FittedBox 而不是灵活,但它不起作用,因为第一个子项的内容具有无限宽度。
SizedBox(
height: 300,
width: 50,
child: Container(
color: Colors.black,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: Container(
height: 100,
color: Colors.red,
),
),
Expanded(
child: Container(
color: Colors.blue,
),
),
],
),
),
);
Run Code Online (Sandbox Code Playgroud)
我想让第一个孩子(即 TextField)变得灵活,这样如果高度太小,就不会出现难看的黄黑色溢出条。
更新:
下图显示了我真正想做的事情,但它存在溢出问题,因为第一个孩子不灵活。
显示了当我使用灵活时会发生什么。
我正在使用 AnimatedContainer 来更改高度。如果可能的话,我宁愿不使用 SizeTransition。
小智 0
只需将您的代码替换为下一个代码即可(可以将弯曲比率调整为正确的代码):
SizedBox(
height: 300,
width: 50,
child: Container(
color: Colors.black,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
flex:1
child: Container(
height: 100,
color: Colors.red,
),
),
Flexible(
flex:10
child: Container(
color: Colors.blue,
),
),
],
),
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2148 次 |
| 最近记录: |