button - 我们如何在颤动中按下单个按钮执行两个功能
问题描述
RaisedButton(
color: Colors.blueAccent,
onPressed: () =>sendData(); //fun1
signupPage(context) //fun2
child:
Text("Signup"),
)
此代码给出错误..预计会找到 ')'
解决方案
Arrow Function
可以运行单语句功能。
选项:
1 - 您可以运行以下两个功能。
RaisedButton(
color: Colors.blueAccent,
onPressed: () {
sendData(); //fun1
signupPage(context); //fun2
},
child:
Text("Signup"),
)
或者
2 - 您可以在 fun 1 中运行 fun2。
RaisedButton(
color: Colors.blueAccent,
onPressed: () => sendData(context), //fun1
child:
Text("Signup"),
)
void sendData(BuildContext context){
//sendData Code ...
signupPage(context); //fun2
...
}
推荐阅读
- matlab - 扩展卡尔曼滤波器预测更新时间
- python - 从文本中的缩写中查找首字母缩写词
- c# - 在 UI 元素设置期间忽略属性设置调用
- json - 将 json 列表发布到烧瓶路由时出现 TypeError
- mysql - 我正在尝试在触发器上使用算术,但我的触发器不起作用
- c# - Swashbuckle 多态性需要鉴别器作为更新时的第一个属性
- java - 我正在开发一个 spring mvc 项目,我想从两个下拉框和一个文本框提交值
- android - 有什么地方可以上传两个要翻译的字符串 xml 文件吗?
- javascript - 检查样本库/文档 Vue JS 中是否出现相同的值
- python - Django没有从CSS文件加载图像