我在颤振中构建特定布局时遇到问题。
我需要的是:可滚动屏幕,有两列,其中第一列具有一定的(但动态的)高度。第二列具有一定(但动态)高度的一部分,而其余的列我想填充剩余空间。
代码结构。
Row(
children: [
Expanded(
child: Column(children:[
someDynamicHeightWidgetsHere()])),
Expanded(child: Column(children: [
someWidgetsHere(),
here fill remainind space to match the first column]))
]
)
Run Code Online (Sandbox Code Playgroud)
使用IntrinsicHeight,该小部件仅扩展到其子级高度。例如,当高度不受限制并且您希望子级尝试无限扩展以将其自身调整为更合理的高度时,此类非常有用。
例子:
IntrinsicHeight(
child: Row(
children: [
Expanded(
child: Column(
children: [
Container(
height: 800,
color: Colors.blue,
),
],
),
),
Expanded(
child: Column(
children: [
Container(
height: 400,
color: Colors.red,
),
Expanded(
child: Container(
color: Colors.yellow,
),
),
],
),
),
],
),
Run Code Online (Sandbox Code Playgroud)
输出:
| 归档时间: |
|
| 查看次数: |
4510 次 |
| 最近记录: |