Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter button, unwanted extra top and bottom padding

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.

like image 440
wiradikusuma Avatar asked Dec 08 '22 12:12

wiradikusuma


1 Answers

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,
                          ),
like image 194
anmol.majhail Avatar answered Jan 21 '23 11:01

anmol.majhail