【问题标题】:The method 'UserUpdateInfo' isn't defined for the type 'AuthService'没有为“AuthService”类型定义方法“UserUpdateInfo”
【发布时间】:2020-12-14 21:27:06
【问题描述】:

我将 firebase_auth 升级到 ^0.18.0+1,但出现了一些错误:

  • 未定义类“AuthException”。
  • 'getCredential' 已弃用,不应使用。
  • FirebaseAuth.instance.currentUser():表达式不计算为函数,因此无法调用。

我修复了上述问题,但无法修复以下问题:

  • 没有为“AuthService”类型定义方法“UserUpdateInfo”。 尝试将名称更正为现有方法的名称,或定义名为“UserUpdateInfo”的方法。

我该如何解决这个问题?我应该只创建一个 var 并将其传递给 updateInfo 方法吗?

【问题讨论】:

  • AuthService你自己的自定义类吗?
  • 是的,它是一个包含signInWithApple的自定义类。

标签: firebase flutter firebase-authentication


【解决方案1】:

FirebaseAuth api 已随版本 0.18.0 更改。 https://firebase.flutter.dev/docs/migration#authentication

UserUpdateInfo 类已被移除,取而代之的是命名参数,并且 currentUser() 方法不再是异步的。

之前:

          await FirebaseAuth.instance.currentUser().then((val) async {
            final userUpdateInfo = UserUpdateInfo();
            userUpdateInfo.displayName =
                '${appleIdCredential.fullName.givenName} ${appleIdCredential.fullName.familyName}';
            userUpdateInfo.photoUrl = 'define an url';
            await val.updateProfile(userUpdateInfo);
          });

之后:

          await FirebaseAuth.instance.currentUser.updateProfile(
            displayName:
                '${appleIdCredential.fullName.givenName} ${appleIdCredential.fullName.familyName}',
            photoURL: 'define an url',
          );

【讨论】:

    猜你喜欢
    • 2021-09-02
    • 2022-11-21
    • 2021-10-19
    • 2021-07-19
    • 2021-09-01
    • 2021-09-17
    • 2021-06-11
    • 2021-06-28
    • 2021-06-08
    相关资源
    最近更新 更多