So I have an async funtion:
Future decodeToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var token = await prefs.getString('token');
final Map<String, dynamic> payload = json.decode(
ascii.decode(
base64.decode(base64.normalize(token.split(".")[1])),
),
);
return payload;
}
and when I try do do:
var payload = await decodeToken();
it throws an error saying "The await expression can only be used in an async function."
I tried taking out the "await" and print the payload variable but obviously it prints "Instance of Future"
if I do:
decodeToken().then((value)=>print(value))
it prints the value correctly, but I want to use it in a variable, how do I return the vvalue of an async function?