flutter 参数函数_Flutter:我可以将参数传递给按钮上的onPress事件中定义的函数吗?...

我有一个简单的带有按钮的表格来计算表格。我认为最好是按一下按钮以开始计算并将变量传递给哑函数,而不是让函数知道它不需要知道的文本字段。我可以这样做还是我的计算功能需要访问我的TextField?

new Container(

color: Colors.grey.shade300,

padding: new EdgeInsets.all(15.0),

child: new Column(

children: [

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) {

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值