Remove padding in Flutter Container > FlatButton

FlatButton(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,)

FlatButton(
  padding: EdgeInsets.all(0) 
)

did the trick for me


I find it easier to just wrap the button in a ButtonTheme.

Specify the maxWith and height (set to zero to wrap the child) and then pass your button as the child.

You can also move most of your button properties from the button to the theme to gather all properties in one widget.

ButtonTheme(
  padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0), //adds padding inside the button
  materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, //limits the touch area to the button area
  minWidth: 0, //wraps child's width
  height: 0, //wraps child's height
  child: RaisedButton(onPressed: (){}, child: Text('Button Text')), //your original button
);

Tags:

Flutter