title: Why button needs to be pressed twice for state update in flutter using provider?
body: <p>I am fairly new to flutter just been a few days.</p>
  
  <p>I am trying my hands on provider pattern, and find it easy to use and understand. However, after implementing i found the button is needed to press twice for the update of state.</p>
  
  <p>I have checked everywhere, like double function call and nothing seems wrong. 
  Here is the code.</p>
  
  <pre><code>    class CounterPage extends StatelessWidget {
  
    final changeName = TextEditingController();
    final changeNumber = TextEditingController();
  
    @override
    Widget build(BuildContext context) {
      final CounterBloc counterBloc = Provider.of&lt;CounterBloc&gt;(context);
      return Scaffold(
        appBar: 
        AppBar(
          title: Text(counterBloc.name.toString()),
        ),
        body: Container(
          child: Center(
            child: Column(
              children: &lt;Widget&gt;[
                Text(
                  counterBloc.counter.toString(),
                  style: TextStyle(fontSize: 62.0),
                ),
                TextField(
                  controller: changeName,
                ),
                  TextField(
                  controller: changeNumber,
                ),
                IncrementButton( changeNumber.text, changeName.text),
              ],
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>The nomenclature is wrong, the use of the increment button is to, just pass two string and set to some places in UI using provider.</p>
  
  <p>This is what my increment button looks like, SImple nothing fancy</p>
  
  <pre><code>   class IncrementButton extends StatelessWidget{
  
    final String name;
    final String number;
    IncrementButton(this.name, this.number);
    @override
    Widget build(BuildContext context) {
      final CounterBloc counterBloc = Provider.of&lt;CounterBloc&gt;(context);
      return FlatButton.icon(
        icon: Icon(Icons.add),
        label: Text("Add"),
        onPressed: ()=&gt;counterBloc.nameAndCounter(name,number),
      );
    }
  
  }
  </code></pre>
  
  <p>And this is what counterBloc looks like</p>
  
  <pre><code>   import 'package:flutter/material.dart';
  
  class CounterBloc extends ChangeNotifier{
  
    String _counter = "10";
    String _name ="Alphhit";
  
    String get counter =&gt; _counter;
    String get name =&gt; _name;
     nameAndCounter( String name, String digit){
      _name =  name;
      _counter = digit;
  
      notifyListeners();
    }
  }
  </code></pre>
  
  <p>The state gets updated and reflected only after pressing the button twice?
  Can someone please tell what I am doing wrong ?</p>