相关疑难解决方法(0)

如何在Flutter中拉伸图像以适应整个背景(100%高度x 100%宽度)?

我的图像与设备屏幕的宽高比不匹配.我想拉伸图像,使其完全填满屏幕,我不想裁剪图像的任何部分.

CSS具有百分比的概念,因此我可以将高度和宽度设置为100%.但看起来Flutter似乎没有这个概念,只是硬编码高度和宽度是不好的,所以我被卡住了.

这就是我所拥有的(我使用的是Stack,因为我在图像的前景中有一些东西):

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,
  ],
);
Run Code Online (Sandbox Code Playgroud)

containers image stretch flutter

20
推荐指数
9
解决办法
2万
查看次数

如何在flutter中让栈中的孩子等高?

如何在flutter中让栈中的孩子等高?下面的容器是自动高度,我需要根据下层容器的高度来设置上层容器的高度。

\n

为什么我需要这个\xef\xbc\x9f

\n

因为我想实现一个后台进度条。

\n
return Stack(\n  children: [,\n    Container(\n      //how to auto set this widget equal height to below.\n      height:?\n    ),\n    Container(\n      child: Column(\n        children: [\n          Text("a"),\n          Text("b"),\n          Text("c"),\n          //maybe more widgets..\n        ],\n      ),\n    ),\n  ],\n);\n
Run Code Online (Sandbox Code Playgroud)\n

flutter

2
推荐指数
1
解决办法
3341
查看次数

标签 统计

flutter ×2

containers ×1

image ×1

stretch ×1