title: Unable to access Provider in new page route Widget
body: <p>I am unable to access the Provider in a Widget that I pushed onto the current Navigator:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter/foundation.dart';
  import 'package:provider/provider.dart';
  
  
  void main() =&gt; runApp(MyApp());
  
  class MyModel with ChangeNotifier {
    String a = 'Test1';
    String b = 'Test2';
  }
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {    
  
      return MaterialApp(
          title: 'Flutter Demo',
          home: ChangeNotifierProvider(
              create: (context) =&gt; MyModel(),
              child: MyHomePage()
          )
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key}) : super(key: key);
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
    @override
    Widget build(BuildContext context) {    
  
      return Consumer&lt;MyModel&gt;(
          builder: (context, myModel, child) =&gt;
              Scaffold(
                appBar: AppBar(
                  title: Text(myModel.a),
                ),
                floatingActionButton: FloatingActionButton(
                  onPressed: () =&gt;
                      Navigator.of(context).push(
                          PageRouteBuilder(
                              pageBuilder: (context, animation, secondaryAnimation) =&gt; Page2(),
                          ),
                      ),
                  tooltip: 'Press',
                  child: Icon(Icons.add),
                ),
              )
      );
    }
  }
  
  class Page2 extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
      var myModel = Provider.of&lt;MyModel&gt;(context); // A
  
      return Scaffold(
                appBar: AppBar(
                  title: Text(myModel.b),
                ),
              );
    }
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>The following ProviderNotFoundException was thrown building Page2(dirty):
  Error: Could not find the correct Provider&lt;MyModel&gt; above this Navigator Widget
  </code></pre>
  
  <p>The issue seems to be that the BuildContext object in the Page2 widget is not the same BuildContext that's associated with the Provider.  If I pass a reference of original context to Page2 and use that at point (A), everything works, but this doesn't seem to be a good way of solving this problem.</p>
  
  <p>I tried the solution <a href="https://stackoverflow.com/a/55218112/2233706">here</a>, by using <code>Navigator.of(context, rootNavigator: true).context</code> as the context inside the <code>build</code> method of Page2, but I still get the same exception.</p>