getStorageValue method
Retrieve a value from the storage, based on a key and the logged-in user.
This method first retrieves the current user and then gets the value associated with the provided key from the storage.
key
: The key whose associated value is to be retrieved.
Returns a Future<dynamic>
that completes with the retrieved value.
Example:
final value = await authRequest.getStorageValue('exampleKey');
Implementation
Future<dynamic> getStorageValue(String key) async {
try {
// Retrieve the current user.
final currentUser = await getCurrentUser();
// If the user is not null, get the user property from the storage.
if (currentUser != null) {
return CoffeeStorage.getUserProperty(currentUser, key);
}
// ignore: empty_catches
} catch (e) {}
return null;
}