我正在构建一个屏幕,它有一个底部导航栏,我在其中放置了一个汉堡操作按钮和一个 float 按钮,还有一个应用栏,我想在其中放置我的应用程序 Logo 。
即使我没有对应用栏进行任何操作,汉堡图标仍然出现在标题的左侧。
我只想在应用栏中显示标题。
这是我的代码:
appBar: new AppBar(
title: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
actions: null,
backgroundColor: Colors.black,
elevation: 0.0,
),
key: _scaffoldKey,
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
child: ImageIcon(new AssetImage("assets/icons/star.png"), color: Colors.black),
backgroundColor: Colors.white,
onPressed: scan,
),
bottomNavigationBar: BottomAppBar(
color: Color.black,
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(icon: Icon(Icons.menu), color: Colors.white, onPressed: ()=> _scaffoldKey.currentState.openDrawer(),),
],
),
),
最佳答案
如果脚手架有一个抽屉并且应用栏不包含“leading”属性(或具有空值),应用栏将在其操作中附加一个菜单图标。
它在 documents 中提到:
If the leading widget is omitted, but the AppBar is in a Scaffold with a Drawer, then a button will be inserted to open the drawer. Otherwise, if the nearest Navigator has any previous routes, a BackButton is inserted instead. This behavior can be turned off by setting the automaticallyImplyLeading to false. In that case a null leading widget will result in the middle/title widget stretching to start.
解决方案很简单,只需将应用栏中的 title
属性替换为 leading
appBar: new AppBar(
leading: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
actions: null,
backgroundColor: Colors.black,
elevation: 0.0,
),
关于android-studio - flutter 应用栏中不需要的操作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51579236/