我的资产文件夹中存储了各种图标,包括大小为 155x118 的 Gmail 图标、大小为 126x126 的 Twitter 图标和大小为 122x122 的 LinkedIn 图标。我的目标是在一行中显示这些不同的图标,并且我创建了以下代码来实现此目的。
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const Icon(
Icons.facebook,
// size: 36, // Specify the size you want for built-in icons
),
onPressed: () {
// Handle Facebook login or navigation
},
),
IconButton(
icon: Image.asset(
'assets/twitter.png', // Path to your custom icon
width: 36, // Adjust the width as needed
height: 36, // Adjust the height as needed
),
onPressed: () {
// Handle the custom icon button click
},
),
IconButton(
icon: Image.asset(
'assets/linkedin.png', // Path to your custom icon
width: 36, // Adjust the width as needed
height: 36, // Adjust the height as needed
),
onPressed: () {
// Handle the custom icon button click
},
),
IconButton(
icon: Image.asset(
'assets/whatsapp.png', // Path to your custom icon
width: 36, // Adjust the width as needed
height: 36, // Adjust the height as needed
),
onPressed: () {
// Handle the custom icon button click
},
),
IconButton(
icon: Image.asset(
'assets/gmail.png', // Path to your custom icon
width: 36, // Adjust the width as needed
height: 36, // Adjust the height as needed
),
onPressed: () {
// Handle Gmail login or navigation
},
),
],
)
此代码显示不同大小的图像图标,LinkedIn 和 WhatsApp 图标显示得比预期小。我正在寻求帮助来解决此问题。有谁可以帮帮我吗
这是图片链接
您可以使用
IconButton
中的 IconButton
。
IconButton(
iconSize: 36,//your value
对于图像,尝试使用
fit:BoxFit.cover
Image.asset(
"",
fit: BoxFit.cover,
)