0

I have a Drawer widget on main.dart. The Drawer works great on this page, but when I navigate to a different page, using code like below, I lose the the drawer on the new page. Is there any recommended way to keep the drawer after navigating to a separate page?

Navigator.push(context, new MaterialPageRoute(builder: (context) => new MessageEntryPage()));

I saw similar questions in stackoverflow but couldn't get an answer.

1 Answers1

0

not use Navigator.push

instance of body change

for example

return Scaffold(
  appBar: AppBar(
    title: Text(widget.title),
  ),
  drawer: your drawer ,
  body:  // your Widget
  floatingActionButton: FloatingActionButton(
    onPressed: _incrementCounter,
    tooltip: 'Increment',
    child: Icon(Icons.add),
  ), 
);

When we change the drawer, we use setState to change the widget on the body

Junsu Cho
  • 826
  • 7
  • 16