4

I'm trying to customize a Flutter button:

ButtonTheme(
    child: FlatButton(
        child: Text(_text),
        color: _color,
        onPressed: _onPressed,
    ),
    minWidth: 40,
),

But I can't get rid of the extra top and bottom padding:

Extra padding

FlatButton, RaisedButton, MaterialButton, all of them have the padding.

NOTE: I have more customizations, such as padding, text trimming, and border-radius.

wiradikusuma
  • 1,930
  • 4
  • 28
  • 44

2 Answers2

14

To remove that padding add - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,

ButtonTheme(
                            child: FlatButton(
                              materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,  // add this
                              child: Text('Dummy'),
                              color: Colors.blue,
                              onPressed: () {},
                            ),
                            minWidth: 40,
                          ),
anmol.majhail
  • 48,256
  • 14
  • 136
  • 105
0

Set padding to 0 for your ButtonTheme like shown below

    new ButtonTheme(
      padding: new EdgeInsets.all(0.0),
      child: FlatButton(
        child: Text(_text),
        color: _color,
        onPressed: _onPressed,
        ),
      minWidth: 40,
    ),
Thanthu
  • 4,399
  • 34
  • 43