title: Using Provider in the same widget in flutter
body: <p>I have declared MultipleProviders in my widget and i want to use it to change the color of the App by assaining the variable to the ThemeData Primary swatch but it's giving me this error related to provider . and i have use in other widgets and it's working .i think i am getting this error bacause i am using it in the same widget how i can solve it ?</p>
  <pre><code>void main() =&gt; runApp(MyApp());
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      var u = Provider.of&lt;prov&gt;(context);
      return MultiProvider(
        providers: [ChangeNotifierProvider(create: (_)=&gt;prov())],
        child: GetMaterialApp(
          theme: ThemeData(primarySwatch: u.col),
          title: 'Material App',
          home: f(),
        ),
      );
  
    }
  } 
  </code></pre>
  <p>this is the error</p>
  <p>Error: Could not find the correct Provider above this MyApp Widget</p>
  <p>This happens because you used a <code>BuildContext</code> that does not include the provider
  of your choice. There are a few common scenarios:</p>
  <ul>
  <li><p>You added a new provider in your <code>main.dart</code> and performed a hot-reload.
  To fix, perform a hot-restart.</p>
  </li>
  <li><p>The provider you are trying to read is in a different route.</p>
  <p>Providers are &quot;scoped&quot;. So if you insert of provider inside a route, then
  other routes will not be able to access that provider.</p>
  </li>
  <li><p>You used a <code>BuildContext</code> that is an ancestor of the provider you are trying to read.</p>
  <p>Make sure that MyApp is under your MultiProvider/Provider.
  This usually happens when you are creating a provider and trying to read it immediately.</p>
  <p>For example, instead of:</p>
  <pre><code>Widget build(BuildContext context) {
    return Provider&lt;Example&gt;(
      create: (_) =&gt; Example(),
      // Will throw a ProviderNotFoundError, because `context` is associated
      // to the widget that is the parent of `Provider&lt;Example&gt;`
      child: Text(context.watch&lt;Example&gt;()),
    ),
  }
  </code></pre>
  <p>consider using <code>builder</code> like so:</p>
  <pre><code>Widget build(BuildContext context) {
    return Provider&lt;Example&gt;(
      create: (_) =&gt; Example(),
      // we use `builder` to obtain a new `BuildContext` that has access to the provider
      builder: (context) {
        // No longer throws
        return Text(context.watch&lt;Example&gt;()),
      }
    ),
  }
  </code></pre>
  </li>
  </ul>