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();}
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.