Reputation: 533
I want to add both back button and hamburger icon in my flutter app? This is useful especially in iOS faster navigation to root pages in deep navigation.
Upvotes: 1
Views: 1636
Reputation: 5273
I would just put the hamburger button at the right of the screen using the endDrawer
attribute:
Scaffold(
appBar: AppBar(title: Text("...")),
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
...
],
),
),
body: ...);
Upvotes: 0
Reputation: 3225
You probably want to do something like this: (inside your Scaffold
)
appBar: AppBar(leading: Row(children:[FirstIcon(), SecondIcon(),],),
To open the Drawer
, you will have to do this: (in your widget's build
method):
/// create a Drawer key
final GlobalKey<ScaffoldState> _drawerKey = GlobalKey();
/// this function opens the drawer
void _openDrawer()=>_drawerKey.currentState.openDrawer();
/// then use it to open the Drawer
Scaffold(appBar: AppBar(leading: Row(children: <Widget>[IconButton(onPressed:_openDrawer, icon:Icon(Icons.hamburger,),), SecondIcon(),],),
),);
Edit:
Don't forget to add the _drawerKey
to your Drawer
. Like this:
Drawer(key: _drawerKey, child: YourWidget(),),
Upvotes: 2