Search code examples
flutter

How to remove the hamburger button from a flutter drawer?


I've seem examples on how to set up a drawer in Flutter (return new Scaffold(drawer: new Drawer( ... ) or return new Scaffold(endDrawer: new Drawer( ... )).

How can I remove the hamburger button at the top (so that you can only get the drawer through sliding from the side (or through a custom button in the app - that I know how to do))?


Solution

  • Just set the leading property in your AppBar to an empty Container

    appBar: new AppBar(
              leading: new Container(),
        ....
    

    And in order to remove endDrawer (for RtL). It is placed where the action property is, so also just add an empty Container as a single child of the action property

    appBar: new AppBar(
            actions: <Widget>[
              new Container(),
            ],
    .....