小编Kai*_*han的帖子

Flutter 错误 Firebase 用户 ReauthenticateWithCredential

我正在 flutter 中开发一个应用程序,我需要重新验证用户,但出现以下错误

I/flutter (14968): Error: NoSuchMethodError: The method '[]' was called on null
I/flutter (14968): Receiver: null
I/flutter (14968): Tried calling: []("user")    
Run Code Online (Sandbox Code Playgroud)

下面是我用来重新验证用户身份的代码

FirebaseUser user = await FirebaseAuth.instance.currentUser();
  print("User Email: ${user.email}");
  AuthCredential authCredential = EmailAuthProvider.getCredential(
    email: user.email,
    password: _oldPassController.text,
  );
  print("Auth Credential: ${authCredential.toString()}");
  user.reauthenticateWithCredential(authCredential).then((result) {
    print("Success: $result");
  }).catchError((error) {
    print("Error: $error");
    setState(() {
      _isLoading = false;
    });
    if (error is PlatformException) {
      PlatformException exception = error;
      showAlertDialog(context, exception.message);
    } else {
      showAlertDialog(context, error.toString());
    }
  });
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication flutter

6
推荐指数
1
解决办法
4307
查看次数