如何调整图像宽度并隐藏颤动中的垂直溢出
我正在尝试整理一个简单的模板作为学习练习。我希望图像宽度从一侧到另一侧占据屏幕,并且将高度剪裁为 200px,隐藏多余的所有内容。
代码:
Image _buildJournalHeaderImage(context) {
return Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Salto_del_Angel-Canaima-Venezuela08.JPG/1200px-Salto_del_Angel-Canaima-Venezuela08.JPG",
// fit: BoxFit.cover,
fit: BoxFit.fitWidth,
height: MediaQuery.of(context).size.width / 2,
);
}
此方法被放置为列子级。
I'm trying to put together a simple template as a learning exercise. I want the image width to occupy the screen side to side, and the height to be clipped at 200px hiding everything in excess.
code:
Image _buildJournalHeaderImage(context) {
return Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Salto_del_Angel-Canaima-Venezuela08.JPG/1200px-Salto_del_Angel-Canaima-Venezuela08.JPG",
// fit: BoxFit.cover,
fit: BoxFit.fitWidth,
height: MediaQuery.of(context).size.width / 2,
);
}
this method is placed as a column child.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要比这更复杂的东西来让图像填充宽度并具有 200 的固定高度:
You should not need anything more complex than this to have the image fill the width and have a fixed-height of 200:
像这样创建
示例代码 dartpad 实时代码
Create like this
SampleCode dartpad livecode