title: Flutter Provider's methods cant be called from classes
body: <p>i have used provider package to manage flutter apps state, but i am facing many problems in using it.
  i have defined a simple provider which has one Boolean variable and one method that change the variable value</p>
  
  <pre><code>
  
  
       class LoadingModel with ChangeNotifier{
        bool is_loading=false;
  
        changeLoadingState(){
          is_loading = !is_loading;
          notifyListeners();
        }}
  
  </code></pre>
  
  <p>now i want to call changeLoadingState() method that defined in the provider from MyApp class in the main page and here is the main page code</p>
  
  <pre><code>
  
      void main() => runApp(MyApp());
  
      class MyApp extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider(
        create: (context) => LoadingModel(),
        child: MaterialApp(
          home:Scaffold(
            body: Center(
              child: Wrap(children: [
              Column(children: [
                  RaisedButton(
                child: Text("hide the progress"),
                onPressed: () {
                 Provider.of(context,listen: false).changeLoadingState();
  
                  },
              )
  
              ],)
              ],)
            ),
          )
        ), 
      );
    }
  }
  
  </code></pre>   
  
  <p>but when i run the app the console display </p>
  
  <p>Error: Could not find the correct Provider above this MyApp Widget</p>
  
  <p>To fix, please:</p>
  
  <ul>
  <li>Ensure the Provider is an ancestor to this MyApp Widget</li>
  <li>Provide types to Provider</li>
  <li>Provide types to Consumer</li>
  <li>Provide types to Provider.of()</li>
  <li>Always use package imports. Ex: `import 'package:my_app/my_code.dart';</li>
  <li>Ensure the correct <code>context</code> is being used.</li>
  </ul>
  
  <p>If none of these solutions work, please file a bug at:
  <a href="https://github.com/rrousselGit/provider/issues" rel="nofollow noreferrer">https://github.com/rrousselGit/provider/issues</a></p>
  
  <p>how i can solve this problem???      </p>