首页 > 解决方案 > 在颤动中减少应用栏按钮中的填充

问题描述

如何减少按钮之间的间距?

你可以看到应用栏上的四个按钮占用了很多空间,我试过行。但没有工作

在此处输入图像描述 下面是我的代码——

 AppBar(
  backgroundColor: Colors.deepOrange,
  iconTheme: new IconThemeData(color: Colors.white),
  title: Text(
    titleString,
    style: TextStyle(color: Colors.white),
  ),

  actions: <Widget>[

    IconButton(

      icon: Icon(
        Icons.search,
        color: Colors.white,
      ),
      //iconSize: 20,
      onPressed: null,
    ),
    IconButton(
      icon: Icon(
        Icons.notifications_none,
        color: Colors.white,
      ),
     // iconSize: 20,

      onPressed: null,
    ),
    //Add more icon here

  ],
);

标签: flutterdartappbar

解决方案


问题出在IconButton小部件上。默认情况下,大小为 48x48 像素大小,您可以在此问题的最佳答案中IconButton了解它。

一种解决方法是使用GestureDetector小部件来处理您的onPressed()方法。下面是一个例子。

actions: <Widget>[
          GestureDetector(
              onTap: (){
                //your code
              },
              child: Icon(Icons.search)
          ),
          GestureDetector(
              onTap: (){},
              child: Icon(Icons.notifications)
          )
          //Add more icon here
        ],

推荐阅读