title: Flutter: Can I pass arguments to a function defined in an onPress event on a button?
body: <p>I have a simple form with a button to calculate the form. I figure it's better to hit the button to start the action of calculating and pass the variables to the dumb function than to make the function aware of text fields it shouldn't need to know about. Can I do that or does my calculate function need to access my TextFields?</p>
  
  <pre><code>         new Container(
              color: Colors.grey.shade300,
              padding: new EdgeInsets.all(15.0),
              child: new Column(
                children: &lt;Widget&gt;[
                  new TextField(
                    controller: _ageController,
                    decoration: new InputDecoration(
                        icon: new Icon(Icons.person_outline), labelText: "Age"),
                  ),
                  new TextField(
                    controller: _heightController,
                    decoration: new InputDecoration(
                        icon: new Icon(Icons.insert_chart),
                        labelText: "Height (in feet)"),
                  ),
                  new TextField(
                    controller: _weightController,
                    decoration: new InputDecoration(
                        icon: new Icon(Icons.line_weight),
                        labelText: "Weight (in lbs)"),
                  ),
                  new Padding(padding: new EdgeInsets.only(top: 20.0)),
                  new RaisedButton(
                    onPressed: calculate(1, 2),
                    color: Colors.pinkAccent,
                    child: new Text(
                      "Calculate",
                      style: new TextStyle(color: Colors.white),
                    ),
                  )
                ],
              ),
            ),
  
          ],
        ),
      );
    }
  
    void calculate(num1, num2) {
  
    }
  }
  </code></pre>