Reputation: 93
I am making a app that does bookings but I get a error about my sign out, this did not happen before I added booking system.
══╡ EXCEPTION CAUGHT BY PROVIDER ╞══════════════════════════════════════════════════════════════════
I/flutter ( 6595): The following assertion was thrown:
I/flutter ( 6595): An exception was throw by _MapStream<FirebaseUser, User> listened by
I/flutter ( 6595): StreamProvider<User>, but no `catchError` was provided.
I/flutter ( 6595):
I/flutter ( 6595): Exception:
I/flutter ( 6595): NoSuchMethodError: The getter 'uid' was called on null.
I/flutter ( 6595): Receiver: null
I/flutter ( 6595): Tried calling: uid
I know this was answered but i cannot use that code since my bookings page is dependent on the one line of code that the sign out doesn't want. my auth page code that my bookings needs:
//create user object based on firebase user
User _userFromFirebaseUser(FirebaseUser user){
userId(user.uid);
//if i comment the above line out my signout works but bookings not
return user != null ? User(uid: user.uid) : null;
}
Upvotes: 2
Views: 473
Reputation: 80934
You got that error because you are already signed out, then there is no user currently logged in. You need to change the code to the following:
User _userFromFirebaseUser(FirebaseUser user){
userId(user?.uid ?? "no user")
return user != null ? User(uid: user.uid) : null;
}
Upvotes: 4