Home > database >  Flutter Dart Firebase error: The function can't be unconditionally invoked because it can be &#
Flutter Dart Firebase error: The function can't be unconditionally invoked because it can be &#

Time:11-26

I want to check if the user is currently registered, but I get a problem with the not null errors. Please have a look at my code:

class _ChatScreenState extends State<ChatScreen> {final _auth = FirebaseAuth.instance; void getCurrentUser() async {
final user = await _auth!.currentUser();}

enter image description here

CodePudding user response:

you're calling it as a Function, but you can get the current user information directly with currentUser, not currentUser():

final _auth = FirebaseAuth.instance;
_auth.currentUser(); // wrong way
_auth.currentUser; // right way

currentUser() doesn't exist, currentUser does.

  • Related