dart - 如何在 Flutter 中移除 AppBar 前导图标周围的额外填充
问题描述
在我的 Flutter 应用程序中,我有这个 AppBar
Widget setAppBar(){
return new AppBar(
title: addAppBarTextWidget('Explore'),
elevation: 0.0,
leading: addLeadingIcon(),
actions: <Widget>[
addAppBarActionWidget(Constant.iconNotification, 22.0, 16.0, 8.0),
addAppBarActionWidget(Constant.iconProfile, 30.0, 30.0, 15.0)
],
);
}
Widget addLeadingIcon(){
return new Container(
height: 25.0,
width: 25.0,
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Image.asset(
Constant.iconNotification,
width: 25.0,
height: 25.0,
),
new FlatButton(
onPressed: (){
onLeadingShowCategoryClick();
}
)
],
),
);
}
看起来像:
正如您在 AppBar 上看到的,前导图标周围有一些额外的填充。我怎样才能删除这个额外的填充。
解决方案
只需添加一个名为 titleSpacing 的属性,
样本
appBar: AppBar(
leading: Icon(Icons.android),
titleSpacing: 0,
title: Text(widget.title),
),
推荐阅读
- .htaccess - 添加“过期标头”导致错误 500
- javascript - 我可以在 Safari 上使用 Web Share API 共享文件吗
- oracle-apex - Oracle Apex 构面值
- javascript - HTML - ReactJS:如何在
- c# - 我可以使用 WebView 接收推送通知并使用 Xamarin 在我的 Android 应用程序上显示它们吗?
- vue.js - VuePress - 用特殊字符填充的降价内容
- kubernetes - 裸机上的 Kubernetes,通过入口暴露服务
- docker - 如何使用在 docker 中退出的同一个容器
- google-cloud-platform - 将 OpenVPN 与 Google VPC 连接后,无法上网
- javascript - 如何根据 id 显示图像(过滤器)