title: How to navigate BottomNavigationBar in another stateless widget
body: <p>I have a BottomNavigationBar in a stateless widget. I'm using ViewModelProvider to control the tab change when onTap event. I have no issue navigating using the BottomNavigationBar, but I was unable to control the navigation bar from inside the body. I'm using the following method, I have tried streambuilder to control the navigation, but streambuilder will dispose of the content when navigate to another tab which is not what I wanted. I am not able to click on button in Profile Page and navigate to Home page.</p>
  
  <p>Below are my widget for BottomNavigationBar.</p>
  
  <pre><code>class BottomNavigationView extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return ViewModelProvider&lt;BottomNavigationViewModel&gt;.withConsumer(
        viewModel: BottomNavigationViewModel(),
        builder: (context, model, child) =&gt; Scaffold(
          primary: false,
          body: IndexedStack(
            children: &lt;Widget&gt;[
              BrowseView(),
              HomeView(),
              ProfileView(),
            ],
            index: model.currentIndex,
          ),
          bottomNavigationBar: BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            backgroundColor: Colors.white,
            currentIndex: model.currentIndex,
            onTap: model.changeView,
            items: [
              BottomNavigationBarItem(
                icon: new Icon(Icons.search),
                title: SizedBox.shrink(),
              ),
              BottomNavigationBarItem(
                icon: new Icon(Icons.home),
                title: SizedBox.shrink(),
              ),
              BottomNavigationBarItem(
                icon: new Icon(WineIcon.person),
                title: SizedBox.shrink(),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>Navigation Bar View Model</p>
  
  <pre><code>class BottomNavigationViewModel extends ChangeNotifier {
    int _currentIndex = 2;
    int get currentIndex =&gt; _currentIndex;
  
    void changeView(int index) {
      _currentIndex = index;
      notifyListeners();
    }
  }
  </code></pre>
  
  <p>Profile View &amp; Profile View Model</p>
  
  <pre><code>class ProfileView extends StatelessWidget {
    const ProfileView ({Key key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return ViewModelProvider&lt;ProfileViewModel&gt;.withConsumer(
        viewModel: ProfileViewModel(),
        builder: (context, model, child) =&gt; Scaffold(
          body: Center(
            child: RaisedButton(
               onPressed: ()=&gt; model.goHome(),
               child:Text('Go to Home'),
            ),
          )
        ),
      );
    }
  }
  
  class ProfileViewModel extends ChangeNotifier {
    final BottomNavigationViewModel _bottomNavigationBar =
        locator&lt;BottomNavigationViewModel&gt;();
  
    void goHome() {
      _bottomNavigationBar.changeView(1);
    }
  }
  </code></pre>