Flutterfire: [firebase auth] FirebaseUser.reauthenticateWithCredential finished with NoSuchMethodError exception

Created on 2 Sep 2019  路  11Comments  路  Source: FirebaseExtended/flutterfire

plugin version:

firebase_core: ^0.4.0+9
firebase_auth: ^0.14.0+5

here is the screenshot
Screen Shot 2019-09-02 at 19 58 26

bug

Most helpful comment

@pawlowskim I've done a PR (https://github.com/FirebaseExtended/flutterfire/pull/237) that should fix this error. I'm waiting for the code review.

All 11 comments

@hungnt-kayac Please provide a small self-contained app that demonstrates the problem. You can include small examples inline if they're enclosed by backticks, or just provide a public link to a github "gist" - https://gist.github.com/.
It's extremely tedious to reproduce the issue having code on a screenshot, as we would have to manually transcribe your example.

@BondarenkoStas
i created a sample app here
https://github.com/nguyentuanhung/flutter_firebase_sample
(for some reason, i don't push the whole flutter project, just lib folder and pubspec.yaml file)

In this example, i login via email, password and then try to reauthenticate with provided email and password

I have the same problem. But my situation is different.
I have an anonymous user that should be converted to an "email and password" one. By using linkWithCredential() and reauthenticateWithCredential() i encounter the same error as hungnt-kayac

I experience the same problem, when I try to re-authenticate user it throw exception:

NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: []("user")

Same here.

  Future<AuthResult> reAuthenticate(String email, String password) {
    return getFirebaseUser().then((FirebaseUser user) {
      AuthCredential credential =
          EmailAuthProvider.getCredential(email: email, password: password);
      return user.reauthenticateWithCredential(credential);
    });
  }

If password is correct it throws:

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

If password is incorrect it returns error (expected):

flutter: PlatformException(ERROR_WRONG_PASSWORD, The password is invalid or the user does not have a password., null)

@pawlowskim I've done a PR (https://github.com/FirebaseExtended/flutterfire/pull/237) that should fix this error. I'm waiting for the code review.

I am still getting the NoSuchMethodError: The method '[]' was called on null., even after updating to version 0.15.0 and running pub get.

W/BiChannelGoogleApi(32652): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@1805007
D/FirebaseAuth(32652): Notifying id token listeners about user ( xxxxxxxxxxxxxxxxxxxxxxxxxxxxx ).
I/flutter (32652): NoSuchMethodError: The method '[]' was called on null.
I/flutter (32652): Receiver: null
I/flutter (32652): Tried calling: []("user")

@feinstein have you tried a flutter clean?

@fabryx92 no I didn't, but I expected pub to respect the minimum version and, pubspec.lock has the right version, but I will give it a try and let you know.

I did a flutter clean > pub get > pub upgrade > Stopped and Restarted the App > Confirmed pubspec.lock has firebase_auth 0.15.0+1 and it worked, thanks @fabryx92

@feinstein awesome! I think a previous version of the package was cached, sometimes this happens even after doing pub get.

Was this page helpful?
0 / 5 - 0 ratings