首页 文章

颤动appbar中的不需要的操作按钮

提问于
浏览
2

我正在构建一个屏幕,其中有一个底部导航栏,我在其中放置了一个汉堡操作按钮和一个浮动按钮,以及一个我想放置我的应用徽标的appbar .

即使我没有对appbar进行任何操作,汉堡图标仍会出现在 Headers 的左侧 .

我想在appbar中只有 Headers .

这是我的代码:

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(),),
      ],
    ),
  ),

1 回答

  • 0

    如果脚手架有抽屉并且appbar不包含'leading'属性(或具有空值),Appbar将在其动作中附加一个菜单图标 .

    它在_1091209中提到:

    如果省略了前导小部件,但AppBar位于带抽屉的脚手架中,则会插入一个按钮以打开抽屉 . 否则,如果最近的导航器具有任何先前的路径,则会插入BackButton . 可以通过将automatedImplyLeading设置为false来关闭此行为 . 在这种情况下,空的前导小部件将导致中间/ Headers 小部件拉伸开始 .

    解决方案很简单,只需在您的appbar中用 leading 替换 title 属性即可

    appBar: new AppBar(
            leading: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
            actions: null,
            backgroundColor: Colors.black,
            elevation: 0.0,
      ),
    

相关问题