title: Flutter - Multi Page Navigation using bottom navigation bar icons
body: <p>I'm trying to navigate to different pages within my app using the icons in my bottom navigation bar. I have tried many tutorials and can't seem to work out the best way to achieve this. I have created my Homepage (code below) and 2 additional pages, Inbox and Signin, both return simple scaffolds.</p>
  <p>Firstly i'm interested to know if this is the best way to do what i'm trying to achieve and second, how can my code be altered to allow me to navigate to different pages depending on which icon is tapped. I'm aware that the code below doesn't execute, i'm just trying to show what i've tried.</p>
  <p>My code:</p>
  <pre><code>class HomePage extends StatefulWidget {
    @override
    _HomePageState createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
  
    _onTap(int index) {
      Navigator.of(context)
          .push(MaterialPageRoute&lt;Null&gt;(builder: (BuildContext context) {
        return _children[_currentIndex];
      }));}
  
    final List&lt;Widget&gt; _children = [
      HomePage(),
      InboxPage(),
      SignInPage()
    ];
  
    int _currentIndex = 0;
  
    @override
    Widget build(BuildContext context) {
        SizeConfig().init(context);
        return Scaffold(
          appBar: PreferredSize(preferredSize: Size(double.infinity, 75),
            child: AppBar(
                elevation: 0.0,
                centerTitle: false,
                title: Column(
                  children: &lt;Widget&gt;[
                    Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        currentDate,
                        textAlign: TextAlign.left,
                        style: TextStyle(
                            color: titleTextColor,
                            fontWeight: subTitleFontWeight,
                            fontFamily: titleFontFamily,
                            fontSize: subTitleFontSize),
                      ),
                    ),
                    SizedBox(
                      height: 15,
                    ),
                    Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        'Some text here',
                        style: TextStyle(
                            color: titleTextColor,
                            fontWeight: titleTextFontWeight,
                            fontFamily: titleFontFamily,
                            fontSize: titleFontSize),
                      ),
                    ),
                  ],
                ),
                backgroundColor: kPrimaryColor,
                shape: titleBarRounding
            ),
          ),
          body: BodyOne(),
          bottomNavigationBar: BottomNavigationBar(
              currentIndex: _currentIndex,
              type: BottomNavigationBarType.fixed,
              items: [
                BottomNavigationBarItem(
                  icon: Icon(Icons.home),
                  title: Text('Home'),
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.mail),
                  title: Text('Inbox'),
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.account_circle),
                  title: Text('Account'),
  
  
                )
              ],
            onTap: () =&gt; _onTap(_currentIndex),
          ),);
      }
    }
  </code></pre>
  <p>Thanks in advance.</p>