:错误:没有为类“FirebaseAuth”定义getter“gmrethrow”

m4pnthwp  于 2023-01-27  发布在  其他
关注(0)|答案(2)|浏览(127)

突然间,我得到了这个错误,而做的登录和注册过程。
我是在注册界面注册的时候发现的。

bzzcjhmw

bzzcjhmw1#

我在firebase_auth.dart文件中解决了这个问题:

} catch (e) {
      gmrethrow;
    }

我把它改成这样:

} catch (e) {
      rethrow;
    }

问题就解决了。

xe55xuns

xe55xuns2#

您可以这样处理:

@override
  Future<dynamic> loginWithEmailAndPassword(String email, String password) async {
    try {
      await _firebaseAuth.signInWithEmailAndPassword(
          email: email, password: password);
      return FirebaseSignInWithEmailResponse();
    } catch (exception) {
      return _mapLoginWithEmailError(exception);
    }
  }

  ApiError _mapLoginWithEmailError(PlatformException error) {
    final code = error.code;
    if (code == 'ERROR_INVALID_EMAIL') {
      return FirebaseSignInWithEmailError(
          message: 'Your email is not valid. Please enter a valid email',
          type: FirebaseSignInWithEmailErrorType.INVALID_EMAIL);
    } else if (code == 'ERROR_WRONG_PASSWORD') {
      return FirebaseSignInWithEmailError(
          message: 'Your password is incorrect',
          type: FirebaseSignInWithEmailErrorType.WRONG_PASSWORD);
    } else if (code == 'ERROR_USER_NOT_FOUND') {
      return FirebaseSignInWithEmailError(
          message: 'You do not have an account. Please Sign Up to'
              'proceed',
          type: FirebaseSignInWithEmailErrorType.USER_NOT_FOUND);
    } else if (code == 'ERROR_TOO_MANY_REQUESTS') {
      return FirebaseSignInWithEmailError(
          message: 'Did you forget your credentials? Reset your password',
          type: FirebaseSignInWithEmailErrorType.TOO_MANY_REQUESTS);
    } else if (code == 'ERROR_USER_DISABLED') {
      return FirebaseSignInWithEmailError(
          message: 'Your account has been disabled. Please contact support',
          type: FirebaseSignInWithEmailErrorType.USER_DISABLED);
    } else if (code == 'ERROR_OPERATION_NOT_ALLOWED') {
      throw 'Email and Password accounts are disabled. Enable them in the '
          'firebase console?';
    } else {
      return FirebaseSignInWithEmailError(
          message: 'Make sure you have a stable connection and try again'
          type: FirebaseSignInWithEmailErrorType.CONNECTIVITY);
    }
  }

相关问题