3
votes

I'm building a screen which has a bottom navigation bar, where I placed an burger action button and a floating button, and an appbar where I want to place my app logo.

Even though i didn't give any action to the appbar, the burger icon still appears at the left of the title.

I would like to only have the title in the appbar.

This is my code:

   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
I tested your code and there were not any burger Icon in the title bar.please put the whole code here. - Yamin
Ah, sorry, the fact is that the background of the appbar is white, and so is the burgher icon. I will update it - Andrea Grippi

1 Answers

1
votes

If the scaffold has a drawer and the appbar doesn't contain 'leading' property (or with null value), Appbar will append a menu icon in its actions.

It's mentioned in the 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.

The solution is easy, just replace title property with leading in your appbar

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