I added a button in the AppBar by triggering the enddrawer which works exactly what I wanted. However, I wanted to add another button in the body to trigger another Drawer which also slides out from the right.
How can I achieve this? So far I haven’t found any solution except making the Drawer slides from the left.
Scaffold(
key: scaffoldKey
appBar: AppBar(actions: [
IconButton(
onPressed: () {
scaffoldKey.currentState!.openEndDrawer();
},
icon: const Icon(Icons.filter_alt_outlined))
],),
endDrawer: Drawer(...),
body: Column(
children: [
IconButton(
icon: Icon(Icons.sort),
onPressed:() {
// how to open 2nd endDrawer here..
}
)
]
)
)
2
Answers
You can achieve a full example of a Flutter app with two
EndDrawer
options, you can follow this code:I hope this will help you.
A solution would be using the drawer in the body, and using a PopupMenuButton in the appBar