Praveesh Ramroop
Praveesh Ramroop

Reputation: 365

currentUser: The expression doesn't evaluate to a function, so it can't be invoked

I need to update this code, not I'm not sure how. Does anyone have a clue?

_initialize() async{
SharedPreferences prefs = await SharedPreferences.getInstance();
bool loggedIn = prefs.getBool(LOGGED_IN) ?? false;
if(!loggedIn){
  _status = Status.Unauthenticated;
}else{
  await auth.currentUser().then((currentUser) async{
    _user = currentUser;
    _status = Status.Authenticated;
    _userModel = await _userServices.getUserById(currentUser.uid);
  });

}
notifyListeners();

}

Upvotes: 1

Views: 39

Answers (1)

Octet
Octet

Reputation: 1051

"currentUser" is not a method anymore, it's a property.

_initialize() async{
SharedPreferences prefs = await SharedPreferences.getInstance();
bool loggedIn = prefs.getBool(LOGGED_IN) ?? false;
if(!loggedIn){
  _status = Status.Unauthenticated;
}else{

    _user = auth.currentUser;
    _status = Status.Authenticated;
    _userModel = await _userServices.getUserById(_user.uid);


}
notifyListeners();
}

Upvotes: 1

Related Questions