In order to show my username and the ability to edit it, I would like to place a text with the username and an IconButton for editing side by side (or with minimal space between them). However, when I put these two elements in a Row, Flutter keeps a space between them that I can’t remove.
Here is my code:
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"%${userProvider.userAccount?.pseudo}",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeProvider.isDarkMode
? Colors.white
: Colors.grey,
),
),
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
onPressed: () {},
icon: Icon(Icons.edit, size: 15),
),
],
)
Is there a solution to remove or control this space in my code?
>Solution :
You can resolve the issue by changing the IconButton to an InkWell widget. Here’s how you can do it:
InkWell(
onTap: () {
// Add your onTap functionality here
},
child: Icon(Icons.edit, size: 15),
)