【发布时间】:2018-10-29 12:51:00
【问题描述】:
我有一个简单的表格,带有一个按钮来计算表格。我认为最好点击按钮开始计算操作并将变量传递给哑函数,而不是让函数知道它不需要知道的文本字段。我可以这样做还是我的计算函数需要访问我的 TextFields?
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) {
}
}
【问题讨论】:
-
请出示您的代码
-
代码已添加到帖子中。