SizedBox class

官方文档SizedBox class

SizedBox class

A box with a specified size.

具有指定大小的盒子

If given a child, this widget forces its child to have a specific width and/or height (assuming values are permitted by this widget’s parent). If either the width or height is null, this widget will size itself to match the child’s size in that dimension.

如果赋予子控件,Sizedbox会强制它的子控件有指定的宽度和(或者)高度(赋予的值必须是SizedBox的父控件允许的)。如果宽度或者高度为null,SizedBox会在这个维度中将它自己的大小调整为子控件的大小。

If not given a child, this widget will size itself to the given width and height, treating nulls as zero.

如果没有赋予子控件,SizedBox会将会把自己的大小调整给定大小,null即为size zero。

The new SizedBox.expand constructor can be used to make a SizedBox that sizes itself to fit the parent. It is equivalent to setting width and height to double.infinity.

使用 new SizedBox.expand 初始化函数可以创建一个自适应父控件的的SizedBox。它的宽和高相当于被设置为double.infinity(无穷大)。

Sample

This snippet makes the child widget (a Card with some Text) have the exact size 200x300, parental constraints permitting:

SizedBox(
  width: 200.0,
  height: 300.0,
  child: const Card(child: Text('Hello World!')),
)

See also:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值