相当于flutter中的wrap_content和match_parent? [英] The equivalent of wrap_content and match_parent in flutter?

查看:278
本文介绍了相当于flutter中的wrap_content和match_parent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 中,match_parentwrap_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,我将如何更改它以便我可以填充它的 widthheight> 到其父级?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆