title: How to avoid unnecessary rebuilds while using provider in flutter?
body: <p>I am using <strong><a href="https://pub.dev/packages/provider" rel="nofollow noreferrer">provider</a></strong> in my app, but I faced with unnecessary building.</p>
  <p>Example</p>
  <pre><code>class AllWidget extends StatelessWidget{
  
    @override
    Widget build(BuildContext context){
      print('state build called');
      return ChangeNotifierProvider(
              builder: (_) =&gt; MyCounter(),
              child: Column(children: &lt;Widget&gt;[
                    MyCounterText(),
                    MyIncreaseButton(),
                    MyDecreaseButton(),
              ],
            ),
      );
    }
  }
  
  class MyCounterText extends StatelessWidget{
  
    @override
    Widget build(BuildContext context) {
      final myCounter = Provider.of&lt;MyCounter&gt;(context, listen: false);
      print('MyCounterText');
      return Text(myCounter.num.toString());
  
    }
  }
  
  class MyIncreaseButton extends StatelessWidget{
    @override
    Widget build(BuildContext context) {
      final myCounter = Provider.of&lt;MyCounter&gt;(context, listen: false);
      print('MyIncreaseButton');
      return RaisedButton(
        child: Text('Increase +'),
        onPressed: ()=&gt; myCounter.increment(),
      );
  
    }
  }
  
  
  class MyDecreaseButton extends StatelessWidget{
    @override
    Widget build(BuildContext context) {
      final myCounter = Provider.of&lt;MyCounter&gt;(context, listen: false);
      print('MyDecreaseButton');
      return RaisedButton(
        child: Text('Decrease -'),
        onPressed: ()=&gt; myCounter.decrement(),
      );
  
    }
  }
  </code></pre>
  <p>Now if I click on <code>MyIncreaseButton</code> widget, to inscrease the value, the <code>MyDecreaseButton</code> widget builds too, even when I dont click on it.</p>
  <p>And vice versa, if I click on <code>MyDecreaseButton</code> widget, to descrease the value, the <code>MyIncreaseButton</code> widget builds too, even when I dont click on it.</p>
  <p>My Expectation is:</p>
  <p><strong>When clicking <code>MyIncreaseButton</code> widget, <code>MyDecreaseButton</code> widget should not build.</strong></p>