在 Android 中,match_parent
和 wrap_content
用于将小部件相对于其父级的大小自动调整为小部件包含的内容。
在 Flutter 中,默认情况下似乎所有小部件都设置为 wrap_content
,我将如何更改它以填充它的 width
和 height
到它的 parent 那里?
最佳答案
您可以使用小技巧: 假设您有以下要求: (宽度,高度)
包装内容,包装内容:
//use this as child
Wrap(
children: <Widget>[*your_child*])
Match_parent,Match_parent:
//use this as child
Container(
height: double.infinity,
width: double.infinity,child:*your_child*)
Match_parent,Wrap_content :
//use this as child
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[*your_child*],
);
Wrap_content ,Match_parent:
//use this as child
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[your_child],
);
https://stackoverflow.com/questions/42257668/