title: Flutter problem with finding provider context
body: <p>I have a problem with Flutter Provider pattern. After user is redirected to a new screen, the provider could not be found.</p>
  
  <p>Following my previous question (<a href="https://stackoverflow.com/questions/57124258/could-not-find-the-correct-provider-above-this-widget">Could not find the correct provider above this widget</a>) 
  I wrote this code:</p>
  
  <pre><code>class NewRoute extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      final title = 'Tap to select';
      return MaterialApp(
          title: title,
          home: Scaffold(
            appBar: AppBar(
              title: Text(title),
            ),
            body: NewRouteBody()
          ));
    }
  }
  
  class NewRouteBody extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      var user = Provider.of&lt;UserRepository&gt;(context);
      return ListView(...)
  </code></pre>
  
  <p>I did same thing but I get again the error which says that it could not find the correct provider above this widget (<code>NewRouteBody</code>).</p>
  
  <p>Tried to fix it somehow, Googled the answer for a few hours but without success...</p>
  
  <p>Any help is appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is <code>UserRepository</code> which contains pattern:</p>
  
  <pre><code>class UserRepository with ChangeNotifier {
    User user;
    Status _status = Status.Uninitialized;
  
    Status get status =&gt; _status;
    User get getUser =&gt; user;
  ...}
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>Code snippet with ChangeNotifier:</p>
  
  <pre><code>void main() =&gt; runApp(MyApp());
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        theme: ThemeData(
          primarySwatch: Colors.red,
        ),
        home: HomePage(),
      );
    }
  }
  
  class HomePage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider&lt;UserRepository&gt;(
        builder: (context) =&gt; UserRepository.instance(),
        child: Consumer&lt;UserRepository&gt;(
          builder: (context, UserRepository userRepository, _) {
            switch (userRepository.status) {
              case Status.Uninitialized:
                return Login();
              case Status.Unauthenticated:
                return Login();
              case Status.Authenticating:
              case Status.Authenticated:
  
                if(userRepository.getUser.isPrefSet == 0){
                  return Selection();
                }
                return Dashboard();
            }
          },
        ),
      );
    }
  }
  </code></pre>