I have various icons stored in my assets folder, including a Gmail icon of size 155×118, a Twitter icon of size 126×126, and a LinkedIn icon of size 122×122. I aim to display these distinct icons in a single row, and I’ve created the following code to achieve this.
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
},
),
],
)
This code displays image icons of varying sizes, with LinkedIn and WhatsApp icons appearing smaller than desired. I’m seeking assistance to resolve this issue. Is there any one who can help me.
This is the link of the image
2
Answers
You can use
IconButton
fromIconButton
.And for Image, try to use
fit:BoxFit.cover
You should wrap the IconButton with SizedBox and give the iconButton and provide them necessary size and also fit should be cover type,it should work.