相当于flutter中的wrap_content和match_parent? [英] The equivalent of wrap_content and match_parent in flutter?
问题描述
在 Android 中,match_parent
和 wrap_content
用于自动调整小部件相对于其父小部件的大小,以适应小部件包含的内容.
In Android match_parent
and wrap_content
are used to resize the widgets automatically relative to their parent to the content the widget contains.
在 Flutter 中似乎默认所有小部件都设置为 wrap_content
,我将如何更改它以便我可以填充它的 width
和 height
> 到其父级?
In Flutter it seems by default all widgets are set to wrap_content
, how would I change it such that I can fill its width
and height
to that of its parent?
推荐答案
你可以用 little Trick 做到:假设您有以下要求:(宽度,高度)
You can do with little Trick: Suppose you have requirement of : ( 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],
);
这篇关于相当于flutter中的wrap_content和match_parent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!