title: Not able to access the provider in flutter
body: <p>I have a simple provider class:-</p>
  
  <pre><code>class DataProvider with ChangeNotifier {
     int count;
     void updateCount() {
       count = count + 1;
       notifyListeners();
     }
  }
  </code></pre>
  
  <p>I am attaching this provider to the following class:-</p>
  
  <pre><code>class MyWidget extends StatelessWidget{
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider(
        create: (context) =&gt; DataProvider(),
        child: Scaffold(
          body: raisedButton(
            onPressed: () {
              Provider.of&lt;DataProvider&gt;(context).updateCount();
            }
             child: Text("Click!")
           ),
         ),
       ),
     }
  </code></pre>
  
  <p>and its Giving me the following error:-</p>
  
  <pre><code> I/flutter (32011): Error: Could not find the correct Provider&lt;DataProvider&gt; above this MyWidget 
   Widget
   I/flutter (32011): To fix, please:
   I/flutter (32011):   * Ensure the Provider&lt;DataProvider&gt; is an ancestor to this MyWidget Widget
   I/flutter (32011):   * Provide types to Provider&lt;DataProvider&gt;
   I/flutter (32011):   * Provide types to Consumer&lt;DataProvider&gt;
   I/flutter (32011):   * Provide types to Provider.of&lt;DataProvider&gt;()
   I/flutter (32011):   * Ensure the correct `context` is being used. 
  </code></pre>
  
  <p>What could be the reason for this?</p>
  
  <p><strong>Edit:-</strong>
  It's working fine when I access the provider from any child widget of the widget where I have defined. <code>ChangeNotifierProvider</code>.</p>