A value of type 'Future<FirebaseUser> Function()' can't be assigned to a variable of type 'User'

Viewed 120

This line is causing me trouble

User fUser = FirebaseAuth.instance.currentUser;

FirebaseAuth.instance.currentUser is supposed to return User but dart gives me an error saying that it is returning Future<FirebaseUser> Function() instead. I got this line of code straight from the documentation (https://firebase.flutter.dev/docs/auth/usage). I have already run flutter pub upgrade so I am using the latest version of FirebaseAuth.

Please advise.

1 Answers

Your error is incorrect, I suspect it's from somewhere else.

Anyway, current user is nullable so:

User? fUser = FirebaseAuth.instance.currentUser;
Related