简体   繁体   English

如何解决 facebookauthprovider 中缺少的位置参数?

[英]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.

相关问题 如何解决“Credential”没有为类型“FacebookAuthProvider”定义 - how to Solve 'Credential' isn't defined for the type 'FacebookAuthProvider' send_message() 缺少 1 个必需的位置参数:“消息” - send_message() missing 1 required positional argument: 'message' 如何模拟 Firebase 身份验证提供程序,例如 FacebookAuthProvider? - How to mock Firebase auth providers such as FacebookAuthProvider? 云 Function 错误 runQuery() 缺少 1 个必需的位置参数 - Cloud Function Error runQuery() missing 1 required positional argument authorize() 缺少 1 个必需的位置参数:运行 Google Cloud SDK 示例时的“http” - authorize() missing 1 required positional argument: 'http' when running Google Cloud SDK example 使用 Airflow 导出 BigQuery 表:“extract_table() 缺少 1 个必需的位置参数:‘self’;1764166”错误 - Exporting a BigQuery table with Airflow: "extract_table() missing 1 required positional argument: 'self'; 1764166" error Azure ML 表格数据集:缺少 1 个必需的位置参数:'stream_column' - Azure ML Tabular Dataset : missing 1 required positional argument: 'stream_column' 预期 2 个位置参数,但找到 0 个。 Flutter - 2 positional argument(s) expected, but 0 found. Flutter 如何解决 React Hook useEffect has missing dependencies 错误? - How to solve React Hook useEffect has missing dependencies error? 我该如何解决 FirebaseError:collection() 的预期第一个参数是 CollectionReference、DocumentReference 或 FirebaseFirestore - How can i solve FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM