Flutter 图像宽度、高度未调整到颤振中的参数
我正在尝试缩小图像的比例,这样它就不会在网格项元素中被裁剪。实际图像大小为300x300。 下面是我的代码,我明确地尝试减少图像的宽度和高度,我还尝试了许多适合类型的组合。但我看不到任何明显的影响。你能让我知道我该如何做到这一点吗?谢谢你的耐心Flutter 图像宽度、高度未调整到颤振中的参数,flutter,flutter-layout,Flutter,Flutter Layout,我正在尝试缩小图像的比例,这样它就不会在网格项元素中被裁剪。实际图像大小为300x300。 下面是我的代码,我明确地尝试减少图像的宽度和高度,我还尝试了许多适合类型的组合。但我看不到任何明显的影响。你能让我知道我该如何做到这一点吗?谢谢你的耐心 @override Widget build(BuildContext context) { return Scaffold( body: GridView.count( padding: const E
@override
Widget build(BuildContext context) {
return Scaffold(
body: GridView.count(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
childAspectRatio: 1.5,
crossAxisCount: 2,
children: List.generate(
8,
(index) {
return Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(5),
child: CircleAvatar(
backgroundImage: Image.asset(
'assets/icons/antenna_icon.png',
height: 30,
width: 30,
fit: BoxFit.fitWidth,
).image,
backgroundColor: Colors.grey.shade300,
radius: 50,
)),
Text(
"Evve",
style: GoogleFonts.roboto(color: Colors.black87, fontSize: 15),
),
],
));
},
),
));
}
您可以使用
Transform.scale
作为CircleAvatar
的子级,并将图像设置为Transform.scale
的子级:
CircleAvatar(
child: Transform.scale(
scale: 0.8,
child: Image.asset(
'assets/icons/antenna_icon.png',
height: 30,
width: 30,
fit: BoxFit.fitWidth,
),
),
backgroundColor: Colors.grey.shade300,
radius: 50,
)