getToken function
Retrieves the stored token from SharedPreferences.
Returns a Map<String, dynamic>?
containing the token data if available,
or null
if no token is stored.
Implementation
Future<Map<String, dynamic>?> getToken() async {
SharedPreferences sp = await SharedPreferences.getInstance();
String? data = sp.getString(SharedPrefrenceStorage.token); // Get stored token.
Map<String, dynamic> map = {};
if (data != null) {
map = json.decode(data); // Decode the JSON string back into a map.
}
return map;
}