如何在Flutter中删除AppBar前导图标周围的多余填充 [英] How to remove extra padding around AppBar leading icon in Flutter
本文介绍了如何在Flutter中删除AppBar前导图标周围的多余填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Flutter应用中,我有这个AppBar
In my Flutter app, I have this 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上可以看到,
前导图标周围有一些额外的填充。如何删除多余的填充。
As you can see on the AppBar, there is some extra padding around the leading icon. How can I remove this extra padding.
推荐答案
您不能执行此操作,因为它是预定义的小部件。
但是,您可以执行以下操作:
You can't do this because it is a predefined widget. You can, however, do this:
appBar: AppBar(
automaticallyImplyLeading: false, // Don't show the leading button
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(Icons.arrow_back, color: Colors.white),
),
// Your widgets here
],
),
),
在 automaticallyImplyLeading:true
会隐藏前导 IconButton
的位置,以便您可以添加自己的小部件。
Where automaticallyImplyLeading: true
hides the leading IconButton
so you can add your own widgets.
这篇关于如何在Flutter中删除AppBar前导图标周围的多余填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文