gpt4 book ai didi

button - 我们如何在 flutter 中按下的单个按钮中执行两个功能

转载 作者:IT王子 更新时间:2023-10-29 06:59:01 24 4
gpt4 key购买 nike

RaisedButton(
color: Colors.blueAccent,
onPressed: () =>sendData(); //fun1
signupPage(context) //fun2
child:
Text("Signup"),
)

此代码出错..Expected to find ')'

enter image description here

最佳答案

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
...
}

关于button - 我们如何在 flutter 中按下的单个按钮中执行两个功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54069088/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com