0

Flutter Android Firebase authentication Error, The Authentication passes through but error in the terminal although the Application does not fail

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The getter 'uid' was called on null.

The Error seems to be coming from this Line of code

Future<String> currentUser() async {
    FirebaseUser user = await _firebaseAuth.currentUser();
    return user.uid;
}

1 Answer 1

1

The result of _firebaseAuth.currentUser() was null. Usually that means you are simply not logged in.

Before accessing the current user make sure that you log in. For example using email credentials:

await _firebaseAuth.signInWithEmailAndPassword(email:'[email protected]', password: 'abc123');

The good news is that the firebase package will cache the current user, so after you've logged in you don't have to do it again for a while, you can simply call your currentUser method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.