在 Flutter 布局系统中,我认为将 andFlexible
和放在Expanded
a 中Column
将使 成为Flexible
其子级的大小,并Expanded
占据整个剩余空间。但是,Expanded
不会填满所有剩余空间,并在其后面留下一些空白空间。
这是我想做的:
+-----------------------------+
| Flexible, decides own size. |
+-----------------------------+
| Expanded, fills up the rest |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+-----------------------------+
Run Code Online (Sandbox Code Playgroud)
然而,结果却是这样的:
+-----------------------------+
| Flexible, decides own size. |
+-----------------------------+
| Expanded, takes up only |
| some of the remaining space |
| looks like about 50% of |
| the whole parent |
| |
| |
+-----------------------------+
| LOL here's unused space |
| for no good reason |
| |
+-----------------------------+
Run Code Online (Sandbox Code Playgroud)
我怀疑自己,然后我看到同样的事情被报告为连续的错误: https: //github.com/flutter/flutter/issues/20575
我想我的问题是,如何拥有一个固定大小的小部件(其大小由其子部件决定),然后是一个占据父部件其余部分的小部件?
好吧,答案就是省略Flexible
第一个中的 并将其内容放在那里。然后,Expanded
就可以很好地填满其余的空间。
所以解决方案是这样的:
+------------------------------+
| Just put your self-sized |
| widget here without Flexible |
+------------------------------+
| Expanded, fills up the rest |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+------------------------------+
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2975 次 |
最近记录: |