小编典典

相当于在颤动中wrap_content和match_parent?

flutter

在Android中match_parentwrap_content用于自动调整窗口小部件相对于其父控件的大小,使其相对于窗口小部件包含的内容。

在Flutter中,似乎默认情况下所有小部件都设置为wrap_content,我将如何对其进行更改,以便可以填充其widthheight其父项?


阅读 399

收藏
2020-08-13

共1个答案

小编典典

您可以使用小技巧:假设您有以下要求: (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],
);
2020-08-13