android - 没有边距的 flutter 添加按钮

标签 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),),
            ),
          )
      ),
    );
  }

结果是:

enter image description here

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

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

enter image description here

我怎样才能拥有没有边距的 FlatButton?

最佳答案

根据source .看起来 Flutter 会填充小于目标点击尺寸 (48 x 48) 的按钮,您可以通过以下方式绕过它:

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

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

关于android - 没有边距的 flutter 添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53744731/

相关文章:

android - 在此 Flutter 示例中格式化文本的最佳方式是什么?

flutter - 如何编辑Flutter深色模式

json - 如何在 Flutter 的 POST 请求中将 Map 作为 String 发送?

android - 为 Kotlin 多平台项目运行单元测试时出错

java - 在时间间隔内从日期中减去一天

java - 如何比较带有 ü、ć、š 等特殊字符的字符串?

dart - 如何解决图像选择器崩溃应用程序错误?

android - 使用android :anyDensity

android - 在 AndroidManifest 中注册 Intent.ACTION_DREAMING_STARTED

android - 未放置在第一个 Activity 中时,Flutter Navigation push Replacement 不起作用