0

I'm building a flutter app with persistent bottom navigation bar that contains a menu button. enter image description here

The menu is supposed to open a drawer from any screen and trough the back button it should close it. For that I'm using a scaffold including the bottom navigation widget and also the drawer. This works fine for all screens that are directly accessible trough the bottom navigation bar.

The problem arises if I navigate (I'm using auto_route for routing) to another sub page. In the sub page it seems that it is not possible to close the drawer.

In the sub page I dont provide a Scaffold since I would have nested scaffolds.

I'm using the WillPopScope and onPop looks like this:

if (Scaffold.of(context).isEndDrawerOpen) {
  Navigator.of(context).pop();

Unfortunately this just pops the sub page while the drawer stays open.

One solution would be to pass a closing function to every child screen (or something like a global key for the global scaffold) but I would appreciate a more elegant solution

Do you have any idea how I can fix that? Thanks in advance!

Caspar Bm
  • 258
  • 4
  • 12

0 Answers0