title: Flutter using PageController to change PageView from another class
body: <p>Help I'm a flutter newbie and I've built a file that has OnTap TapGestureRecognizer functions, which I'm trying to manage the pageView within a second page.
  I've tried a few different options and but I can't work out how to get pageController to change the page view on the second page.</p>
  <p>Root Class</p>
  <pre><code>class RootApp extends StatefulWidget {
    @override
    RootAppState createState() =&gt; RootAppState();
  }
  
  class RootAppState extends State&lt;RootApp&gt; {
    bool isFavorite = false;
    int pageIndex = 0;
  
    PageController _pgController = PageController();
  
    void pgCont(pg){
       _pgController.animateToPage(pg, duration: Duration(milliseconds: 250), curve: Curves.bounceInOut);
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: PageView(controller: _pgController,
          children: &lt;Widget&gt;[
          getBody1() ,
          getBody2(),
        ]),
        bottomNavigationBar: getFooter(),
      );
    }
  </code></pre>
  <p>Header Home Class</p>
  <pre><code>class HeaderHomePage extends StatelessWidget {
     HeaderHomePage({
      Key ?key
    }) : super(key: key);
  
     RootAppState rooting = RootAppState();
   }
  
    @override
    Widget build(BuildContext context) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: &lt;Widget&gt;[
          Text.rich(
            TextSpan(
              text: &quot;Body1&quot;,
            recognizer: TapGestureRecognizer()
          ..onTap = (){
                print('He Clicked Body1');
                rooting.pgCont(1);
          },
     SizedBox(
        width: 8,
      ),
      Text.rich(
        TextSpan(
        text: &quot;Body2&quot;,
        recognizer: TapGestureRecognizer()
            ..onTap = (){
          print('She clicked Body2');
          rooting.pgCont(2);
            },),
        style: TextStyle(
            color: white, fontSize: 17, fontWeight: FontWeight.w500),
      )
    ],
  );
  </code></pre>
  <p>Please help I'm stuck on something that seems so simple what I'm I missing or doing wrong here?</p>