title: Using Flutter, what is the correct way to simulate clicks of a FlatButton?
body: <p>Please take a look at this code fragment:</p>
  
  <pre><code>final calculate = new FlatButton(
    child: new Text(_calculate),
    onPressed: _valid
        ? () {
            setState(() {
              model.inTemperature = stringToDouble(strTemperature);
              model.calculateOutTemperature();
            });
          }
        : null);
  </code></pre>
  
  <p>When the button is clicked, <code>setState()</code> is invoked with a lambda that does an assignment and a method invocation. Works perfectly. What I want to do is that, if a text field is submitted, that same <code>setState()</code> is executed.</p>
  
  <p>The easiest way to achieve this would be something like <code>performClick()</code> on that button. Android knows this, for example. However, Flutter has no such method. So, what I do is this:</p>
  
  <pre><code>onSubmitted: (newValue) {
    setState(() {
      strTemperature = newValue.trim();
      calculate.onPressed();
    });
  },
  </code></pre>
  
  <p>This works great, too. My Question is: is it ok to invoke the <code>onPressed()</code> callback on my own? Are there scenarios where my code might break?</p>