相当于在颤动中wrap_content和match_parent?
问题内容:
在Android中match_parent
,wrap_content
用于自动调整窗口小部件相对于其父控件的大小,使其相对于窗口小部件包含的内容。
在Flutter中,似乎默认情况下所有小部件都设置为wrap_content
,我将如何对其进行更改,以便可以填充其width
及height
其父项?
问题答案:
您可以使用小技巧:假设您有以下要求: (Width,Height)
Wrap_content,Wrap_content:
//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],
);