title: No able to get the latest state of an object using provider
body: <p>I am trying get the latest state of the name variable from the Home class, but I am getting a null instead of the value <strong>Tenzin Nyidon</strong>. I initialize the name variable inside the build method of the <strong>MyHomePage</strong> as you can see, and set the <strong>notifyListeners()</strong> method (<em>which notify all listeners</em>) inside the <strong>onPress</strong> of Navigate button.</p>
  
  <p><strong>main.dart:</strong></p>
  
  <pre><code>void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
      return MultiProvider(
        providers: [
          ChangeNotifierProvider&lt;MyHomePage&gt;(builder: (_) =&gt; MyHomePage(),)
        ],
            child: MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
  
            primarySwatch: Colors.blue,
          ),
          home: MyHomePage(),
        ),
      );
    }
  }
  
  
  
  class MyHomePage extends StatelessWidget with ChangeNotifier {
  
     String name; 
  
   @override
    Widget build(BuildContext context) {
      //* Here I intialized the name variabel 
      name = "Tenzin Nyidon";
      return Scaffold(
            body: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: &lt;Widget&gt;[
                  Text(name),
                  RaisedButton(
                    child: Text("Navigate"),
                    onPressed: (){
                      //* notify all listener
                      notifyListeners();
                      Navigator.of(context).push(
  
                        MaterialPageRoute(
                          builder: (_){
                            return Home();
                          }
                        )
  
                      );                  
                      },
                  )
                ],
              ),
        ),
      );
    }
  }
  </code></pre>
  
  <p><strong>home.dart:</strong></p>
  
  <pre><code>class Home extends StatelessWidget {
  
     @override
    Widget build(BuildContext context) {
      var provider = Provider.of&lt;MyHomePage&gt;(context);
      return Scaffold(
        body: Center(
          //! I am getting a null value here
          child: Text("name from the main.dart: ${provider.name}"),
        ),
      );
    }
  }
  </code></pre>