getValue method
Retrieves the current value from cache or SharedPreferences.
If the value is cached, returns the cached value. If not cached but exists in SharedPreferences, retrieves, caches, and returns it. If not found and defaultValue is set, stores the default value and returns it. Returns null if no value is found and no default is set.
Implementation
Future<T?> getValue(SharedPreferencesAsync prefs) async {
if (_cachedValue != null) return _cachedValue;
final exists = await _exists(prefs);
if (!exists && defaultValue != null) {
await setValue(prefs, defaultValue as T);
return defaultValue;
}
return _cachedValue ??= await _getter(prefs, key);
}