21

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))?

Samet ÖZTOPRAK
  • 3,112
  • 3
  • 32
  • 33
Charles Shiller
  • 1,013
  • 4
  • 13
  • 32

6 Answers6

48

In AppBar you need to do the following to hide default rendering hamburger icon

AppBar(
  automaticallyImplyLeading: false, // this will hide Drawer hamburger icon
  actions: <Widget>[Container()],   // this will hide endDrawer hamburger icon
  ... // other props
),

and In SilverAppBar do the following to hide default rendering hamburger icon

SliverAppBar(
  automaticallyImplyLeading: false, // this will hide Drawer hamburger icon
  actions: <Widget>[Container()],   // this will hide endDrawer hamburger icon
  ... // other props
}

I hope this will help...

Aravind Vemula
  • 1,571
  • 17
  • 22
25

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(),
        ],
.....
Shady Aziza
  • 50,824
  • 20
  • 115
  • 113
14

Use the https://docs.flutter.io/flutter/material/AppBar/automaticallyImplyLeading.html property on the AppBar

xster
  • 6,269
  • 9
  • 55
  • 60
7

For the normal drawer you should set https://docs.flutter.io/flutter/material/AppBar/automaticallyImplyLeading.html to false.

For the end drawer you should do the following:

actions: [Container()]
J. van Dijk
  • 395
  • 3
  • 6
1

If you have stacked the AppBar() widget over the top of the SliverAppBar() you need to do automaticallyImplyLeading: false in SliverAppBar() widget only.

This will remove the Hamburger icon from the AppBar.

By the way, why it is happening as such? Could someone tell me?

Am not getting it....

repleeka
  • 550
  • 5
  • 14
1

Simply add this to your Appbar automaticallyImplyLeading: false,

Anand
  • 4,355
  • 2
  • 35
  • 45