Firebase CloudFunctions.GetHttpScalable参数
由于版本0.2.0Firebase CloudFunctions.GetHttpScalable参数,firebase,flutter,google-cloud-functions,Firebase,Flutter,Google Cloud Functions,由于版本0.2.0cloud\u函数用于颤振,请使用.gethttpscalable()而不是.call()。新方法定义为: /// @param functionName The name of the callable function being triggered. /// @param parameters Parameters to be passed to the callable function. HttpsCallable getHttpsCallable( {@re
cloud\u函数
用于颤振,请使用.gethttpscalable()
而不是.call()
。新方法定义为:
/// @param functionName The name of the callable function being triggered.
/// @param parameters Parameters to be passed to the callable function.
HttpsCallable getHttpsCallable(
{@required String functionName, Map<String, dynamic> parameters}) {
return HttpsCallable._(this, functionName);
}
//@param functionName被触发的可调用函数的名称。
///@param parameters要传递给可调用函数的参数。
HttpScalable获取HttpScalable(
{@required String functionName,Map parameters}){
返回HttpScalable.\这是函数名;
}
正如我们所看到的,尽管声明和记录了参数
参数
,但它并没有被使用(我在调试应用程序时通过艰苦的学习了解到了这一点)。因此,我们希望将参数传递给可调用对象上的后续.call()
。为新方法声明参数的原因是什么?虽然我无法解释为什么它是这样设计的,但有些人可能会发现这篇文章使用GetHttpScalable函数寻求帮助。下面是一个使用两个参数(email和password)调用名为addUser的云函数的示例。这些参数通常以另一种方式定义,例如通过TextController的text属性
CloudFunctions.instance.getHttpsCallable(
functionName: "addUser",
).call(
<String, dynamic>{
"email": "test@test.com",
"password": "Terrific password!"
},
);
CloudFunctions.instance.getHttpScalable(
函数名:“addUser”,
).打电话(
{
“电子邮件”:test@test.com",
“密码”:“很棒的密码!”
},
);
我也很想知道为什么,但它确实让代码更清晰了,至少:
HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(
functionName: 'myFunction',
);
try {
HttpsCallableResult response = await callable.call(<String, dynamic>{
'firstParam': firstParam,
'secondParam': secondParam,
});
} catch (e) {
// ...
}
httpscalable callable=CloudFunctions.instance.gethttpscalable(
functionName:'myFunction',
);
试一试{
HttpScalableResult response=wait callable.call({
“firstParam”:firstParam,
“secondParam”:secondParam,
});
}捕获(e){
// ...
}
我投票结束这个问题,因为它看起来像是一个针对特定软件创建者的错误报告。在GitHub上发布关于FlatterFire的问题。