I have a checkLoginStatus()
like this. It will be return true
or false
checkLoginStatus() async {
sharedPreferences = await SharedPreferences.getInstance();
print(sharedPreferences.getString("token"));
if (sharedPreferences.getString("token") != null) {
return true;
}
return false;
}
And I have a button A
with the code below
press: () => {
if(checkLoginStatus()) {
//..Some code
} else {
//..
}
}
I tap on button A
and got
Another exception was thrown: type 'Future<dynamic>' is not a subtype of type 'bool'
Why ? And how can I check checkLoginStatus()
return true
or false
in if()
condition ?