在我的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上看到的那样,前导图标周围有一些额外的填充。如何删除此多余的填充。
您无法执行此操作,因为它是预定义的小部件。但是,您可以这样做:
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,所以你可以添加自己的小部件。
automaticallyImplyLeading: true
IconButton