颤动按钮,多余的顶部和底部填充 [英] Flutter button, unwanted extra top and bottom padding

查看:73
本文介绍了颤动按钮,多余的顶部和底部填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自定义Flutter按钮:

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:

FlatButtonRaisedButtonMaterialButton,它们都有填充.

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

注意:我还有更多自定义设置,例如填充,文本修剪和边框半径.

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

推荐答案

要删除该填充,请添加-materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,

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,
                          ),

这篇关于颤动按钮,多余的顶部和底部填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆