[英]how to solve missing positional argument in facebookauthprovider?
i am using a github project to learn flutter and firebase, but i can figure out what the below 2 errors represent and how to solve them can someone please help我正在使用 github 项目来学习 flutter 和 firebase,但我可以弄清楚以下 2 个错误代表什么以及如何解决它们有人可以帮忙
code:代码:
try {
final FacebookLoginResult facebookLoginResult =
await fbLogin.logIn(['email']);
if (facebookLoginResult.status == FacebookLoginStatus.loggedIn) {
FacebookAccessToken facebookAccessToken =
facebookLoginResult.accessToken;
AuthCredential credential = FacebookAuthProvider.credential(
accessToken: facebookAccessToken.token);
User user = (await auth.signInWithCredential(credential)).user;
print("signed in" + user.displayName);
return user;
}
Errors in Dart analysis tab: Dart 分析选项卡中的错误:
error: 1 positional argument(s) expected, but 0 found.
错误:需要 1 个位置参数,但找到 0 个。 (not_enough_positional_arguments at [flutter_app] lib\login_page.dart:32)
(not_enough_positional_arguments 在 [flutter_app] lib\login_page.dart:32)
error: The named parameter 'accessToken' isn't defined.
错误:未定义命名参数“accessToken”。 (undefined_named_parameter at [flutter_app] lib\login_page.dart:33)
(undefined_named_parameter 在 [flutter_app] lib\login_page.dart:33)
the issue is in this section of the code:问题出在代码的这一部分:
AuthCredential credential = FacebookAuthProvider.credential(
accessToken: facebookAccessToken.token);
You are facing this error because FacebookAuthProvider.credential()
does not taking any named parameter instead it takes a single positional argument accessToken
.您遇到此错误是因为
FacebookAuthProvider.credential()
不采用任何命名参数,而是采用单个位置参数accessToken
。
Replace your line of code with this用这个替换你的代码行
AuthCredential credential =
FacebookAuthProvider.credential(facebookAccessToken.token);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.