I have a Flutter
app with sections that I can access from both a BottomNavigationBar
and a Drawer
. I have this working in a Scaffold
at the root level of my app, and I then use Navigator
widgets to create separate routes and stacks within each section. The BottomNavigationBar
persists as I push new screens onto the stack, and these new screens will have their own AppBar
and actions specific to those user journeys.
The problem is that I need the Drawer
to be present on all of my screens, and setting a new AppBar
in a Scaffold
on individual screens removes the Drawer
that I had set in my root level Scaffold
.
How can I pass that Drawer
through to all my screen AppBar
instances? I don't want to create new Drawer
instances over multiple widgets, so I should create a Singleton
of the Drawer
or even the entire Scaffold
? What's the best practise here?