如何从颤动的抽屉中卸下汉堡包按钮?

Cha*_*ler 5 flutter

我已经似乎 例子就如何建立一个抽屉里扑(return new Scaffold(drawer: new Drawer( ... )return new Scaffold(endDrawer: new Drawer( ... ))。

如何删除顶部的汉堡包按钮(以便只能通过从侧面滑动(或通过应用程序中的自定义按钮-我知道该怎么做)来获得抽屉)?

Ara*_*ula 20

AppBar 中,您需要执行以下操作来隐藏默认呈现的汉堡图标

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

并在SilverAppBar 中执行以下操作以隐藏默认呈现的汉堡包图标

SilverAppBar(
  automaticallyImplyLeading: false, // this will hide Drawer hamburger icon
  actions: <Widget>[Container()],   // this will hide endDrawer hamburger icon
  ... // other props
}
Run Code Online (Sandbox Code Playgroud)

我希望这个能帮上忙...


azi*_*iza 6

只需将leading您的属性设置为AppBarContainer

appBar: new AppBar(
          leading: new Container(),
    ....
Run Code Online (Sandbox Code Playgroud)

并且为了删除endDrawer(用于RtL)。这是摆在那里的action属性,所以也只需添加一个空Container作为一个单一child的的action财产

appBar: new AppBar(
        actions: <Widget>[
          new Container(),
        ],
.....
Run Code Online (Sandbox Code Playgroud)


小智 5

对于普通抽屉,您应该将https://docs.flutter.io/flutter/material/AppBar/automaticallyImplyLeading.html设置为 false。

对于末端抽屉,您应该执行以下操作:

actions: [Container()]
Run Code Online (Sandbox Code Playgroud)