flutter - 在颤动中减少应用栏按钮中的填充
问题描述
如何减少按钮之间的间距?
你可以看到应用栏上的四个按钮占用了很多空间,我试过行。但没有工作
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
],
);
解决方案
问题出在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
],
推荐阅读
- 3d - 如何使用threejs移动或平移场景以使对象居中?
- android - 如何在没有这个白色背景的情况下添加图像?
- server - 为 DICOM 服务器设置正确的标头以与我的 Angular 5 应用程序通信
- javascript - @babel/preset-env 不转译 ES6 类
- google-app-maker - Appmaker 标签中的悬停事件
- swift - 如何快速将文档保存到“文件”应用程序
- javascript - 网页中所有资产的总大小
- javascript - 负前瞻中的字符串被部分捕获
- ruby-on-rails - 如何在 Axlsx 中格式化货币列?
- jquery - ajax 将如何从 golang 代码中获取数据?