skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. 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"),
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search