我有一个简单的表单,其中有一个按钮来计算表单.我认为点击按钮开始计算并将变量传递给哑巴函数要比让函数知道它不应该知道的文本字段要好.我可以这样做吗?或者我的计算函数需要访问我的TextField吗?
new Container(
color: Colors.grey.shade300,
padding: new EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
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) {
}
}