Flutter 添加按钮没有边距

gpa*_*sse 5 android flutter

我正在尝试实现一个没有边距的按钮。

我的代码是:

  @override
  Widget build(BuildContext context) {
    return new AppState(
      child: new Scaffold(

          appBar: AppBar(
            backgroundColor: Color(0xFF031e39),
            title: Text("MY APP"),
          ),
          body:

          ButtonTheme(
            buttonColor: Color(0xFF031e39),
            minWidth: double.infinity,
            child: FlatButton(
              color: Color(0xFF81A483),
              onPressed: () {
                launchSearch();
              },
              child: Text('Search',style: TextStyle(color: Colors.white),),
            ),
          )
      ),
    );
  }
Run Code Online (Sandbox Code Playgroud)

结果是:

在此处输入图片说明

我尝试了所有不同的方法,但我无法找到解决方案,因此按钮没有边距。

如果我将一个小部件放在列中按钮的顶部,我会得到相同的结果:

在此处输入图片说明

我怎么能有一个没有任何边距的 FlatButton ?

Jor*_*ies 27

消息人士透露。看起来 Flutter 填充了小于目标水龙头尺寸 (48 x 48) 的按钮,您可以通过以下方式绕过它:

  1. 使您的按钮高度大于或等于 48

或者

  1. 添加materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,到您的FlatButton.

  • 它节省了我几个小时。 (2认同)