【发布时间】:2018-01-26 11:29:53
【问题描述】:
我的图片与设备屏幕的纵横比不匹配。我想拉伸图像以使其完全填满屏幕,并且我不想裁剪图像的任何部分。
CSS 有百分比的概念,所以我可以将高度和宽度设置为 100%。但是Flutter好像没有这个概念,只硬编码高度和宽度是不好的,所以我卡住了。
这就是我所拥有的(我正在使用堆栈,因为我在图像的前景中有一些东西):
Widget background = new Container(
height: // Not sure what to put here!
width: // Not sure what to put here!
child: new Image.asset(
asset.background,
fit: BoxFit.fill, // I thought this would fill up my Container but it doesn't
),
);
return new Stack(
children: <Widget>[
background,
foreground,
],
);
【问题讨论】:
标签: image flutter dart containers stretch