Flutter:无法从Firebase身份验证中获取错误代码?

Car*_*ein 7 dart flutter

我正在尝试在我的flutter应用程序中使用Google的Firebase身份验证.但是,在处理用户登录时,我似乎找不到"代码"来区分我要处理的异常类型.

Loginhandler.dart:

class LoginHandler {
  String signup(_username, _password) async {
    bool _valid = false;
    final prefs = await SharedPreferences.getInstance();
    FirebaseAuth.instance.createUserWithEmailAndPassword(
          email: _username, password: _password)
          .catchError((e) {
            print(e);
            print(e.message);
            print(e.code);
            print(e.details);
          });
...
Run Code Online (Sandbox Code Playgroud)

错误输出:

W/BiChannelGoogleApi(26738): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@4e727e7
W/IInputConnectionWrapper(26738): getCursorCapsMode on inactive InputConnection
I/flutter (26738): PlatformException(exception, The email address is already in use by another account., null)
I/flutter (26738): The email address is already in use by another account.
I/flutter (26738): exception
I/flutter (26738): null

I/flutter (26738): PlatformException(exception, The given password is invalid. [ Password should be at least 6 characters ], null)
I/flutter (26738): The given password is invalid. [ Password should be at least 6 characters ]
I/flutter (26738): exception
I/flutter (26738): null
Run Code Online (Sandbox Code Playgroud)

我已经按照这个 Stack Overflow线程突出显示我可以使用switch语句,但上面的错误输出没有错误"代码"供我使用.

Feu*_*Feu 1

更新:

这是一个错误,已通过此 PR https://github.com/flutter/plugins/pull/775修复。


根据我的经验,iOS 上有一个错误,你无法获取错误代码,只能获取错误文本消息。在 Android 上,错误代码确实可以正常工作。

在我的应用程序上,我最终检查了错误短信。

该问题已在 flutter 上进行跟踪,您可以订阅该问题并在修复后获取更新。

顺便说一句,这是修复它的拉取请求,但它尚未合并。