Image 根据原始比例使图像变大
如果我有这样的图像:Image 根据原始比例使图像变大,image,flutter,dart,Image,Flutter,Dart,如果我有这样的图像: Column( children: [ Container( child: Image.asset( //this image file, fit: BoxFit.fill, ), ), _buildContents(), ], ), 我想让这个图像大1.5倍或1.2
Column(
children: [
Container(
child: Image.asset( //this image
file,
fit: BoxFit.fill,
),
),
_buildContents(),
],
),
我想让这个图像大1.5倍或1.2倍(或更小),但不超过
在宽度或高度上,我该怎么做?(保持原始比例安全)。请使用Image.asset()的scale属性您应该使用remove
fit:BoxFit.fill
,因为它会根据文档扭曲图像:
BoxFit.fill:通过扭曲源的纵横比来填充目标框
比率
您可以使用列内的Transform.scale
安全地缩放图像,例如:
Transform.scale(
比例:1.50,
子:Image.asset(
文件
)
),
您也可以使用LayoutBuilder小部件,并根据LayoutBuilder小部件提供的约束指定图像的大小尝试BoxFit.contain或BoxFit.cover.Perfect,谢谢