flutter - 相当于flutter中的wrap_content和match_parent?

在 Android 中,match_parentwrap_content 用于将小部件相对于其父级的大小自动调整为小部件包含的内容。

在 Flutter 中,默认情况下似乎所有小部件都设置为 wrap_content,我将如何更改它以填充它的 widthheight 到它的 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/

相关文章:

flutter - 如何禁用 Flutter 中的按钮?

flutter - 未配置 Dart SDK

flutter - 如何在 flutter 中更改包名称?

flutter - 如何使按钮宽度与父级匹配?

flutter - 如何关闭屏幕键盘?

flutter - 如何在 Flutter 中制作圆角图像

flutter - 在 Flutter 中将数据传递给有状态的小部件

flutter - 如何处理不需要的小部件构建?

flutter - 你如何从 Dart 代码中检测宿主平台?

dart - 无状态小部件类中的键是什么?