在此记录项目中所遇到问题及解决方案
正方形的图片能正常显示:
Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: _AssetImage(url)
),
),
)
如果是长方形的图片,上面的代码会显示成“椭圆”
给DecorationImage加一个参数fit=BoxFit.cover就正常显示圆形
Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: _AssetImage(url)
),
),
)
网友评论