title: Navigating to another page from drawer menu and setting title to app bar
body: <p>i am new to flutter and would like someone to help me with code i found in github that i would like to use.  take a look at the link below
  <a href="https://github.com/JohannesMilke/drawer_example" rel="noreferrer">https://github.com/JohannesMilke/drawer_example</a></p>
  
  <p>this is an example of a navigational drawer. i like the way the developer coded it and would like to use this example.  the problem is that the developer didnt implement navigating to another page.  when you click on item in the drawer, it just print a message in the console.</p>
  
  <p>i want to take this a step further.  i want to modified the code so that when you click  on a item it will navigate to another page and the drawer will b closed. the drawer icon should remain on the toolbar on the new page displayed.  also, when you navigate to another page the title of that page should be set in the toolbar.</p>
  
  <p>when i looked at the code , i have an idea where to change but i am not successful. i think i need to change the body tag at the bottom of the code. the problem is that i dont know how to call the DrawerWidgetState class in drawer_widget.dart file.  </p>
  
  <pre><code>
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    final String appTitle =  'Ttitle';
    @override
    Widget build(BuildContext context) =&gt; MaterialApp(
      title: appTitle,
      theme: ThemeData(
        primaryColor: Colors.red,
        textTheme: TextTheme(
          subhead: TextStyle(
            color: Colors.black.withOpacity(0.4),
          ),
        ),
        dividerColor: Colors.black.withOpacity(0.4),
      ),
      home: MainPage(appTitle: appTitle),
    );
  }
  
  class MainPage extends StatefulWidget {
    final String appTitle;
  
    const MainPage({this.appTitle});
  
    @override
    MainPageState createState() =&gt; MainPageState();
  }
  
  class MainPageState extends State&lt;MainPage&gt; {
    @override
    Widget build(BuildContext context) =&gt; Scaffold(
      appBar: AppBar(
        title: Text(widget.appTitle),
      ),
      drawer: DrawerWidget(),
      body: container()
    );
  }
  </code></pre>
  
  <p>i define the following function in drawer_widget.dart file</p>
  
  <pre><code>getDrawerItemWidget(int pos) {
      print('testing');
      switch (pos) {
        case 0:
          return new FirstFragment();
        case 1:
          return new SecondFragment();
        case 2:
          return new ThirdFragment();
  
        default:
          return new Text("Error");
      }
    }
  </code></pre>
  
  <p>but i dont know how to call it from Mainpage Body tag and set title accordingly.  can someone help modify the code so that i can nagivate to another page and set title?  full code is in
  <a href="https://github.com/JohannesMilke/drawer_example" rel="noreferrer">https://github.com/JohannesMilke/drawer_example</a></p>
  
  <p>thanks in advance</p>