I'm new in Flutter, I'm working on a simple authentication app when I registered i should navigate to the chat screen and i want to grab current user but when i call FireBaseAuth.instance.currentUser() I got an exception "the expression doesn't evaluate to a function, so it can't be invoked." Why I'm seeing this? Please Help
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flash_chat/constants.dart';
class ChatScreen extends StatefulWidget {
static const String id = "chatScreen";
@override
_ChatScreenState createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
final FirebaseAuth _auth = FirebaseAuth.instance;
// ignore: deprecated_member_use
FirebaseUser loginUser;
@override
void initState() {
super.initState();
getCurrentUser();
}
void getCurrentUser() async {
// HERE I got an Exception "The expression doesn't evaluate to a function, so it can't be invoked."
final user = await _auth.currentUser();
if (user != null) {
loginUser = user;
print(loginUser.email);
}
}