Reputation: 195
The Default Margin of Buttons is adaptive according to the PlatForm they are used. On Desktop Apps these seems to have no marging and on android, ios it has margin, how to fix this
I have tried changing the Visual density, adjusting the BoxContraints, etc by referring to this and those does not work.
Upvotes: 0
Views: 93
Reputation: 119
Easy Method. Please review this code
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
icon: Icon(Icons.access_alarm),
onPressed: () {},
)
ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {},
child: Text("Click Me"),
)
Upvotes: 1
Reputation: 195
The actual solution is to use tapTargetSize: MaterialTapTargetSize.padded
for margin and tapTargetSize: MaterialTapTargetSize.shrinkWrap
for removing the margin. Hope this helps.
You can also define materialTapTargetSize: MaterialTapTargetSize.padded
on your ThemeData
to set margin accross the app for all supported widgets.
Upvotes: 0