getValue method

  1. @override
Future<T?> getValue(
  1. SharedPreferencesAsync prefs
)
override

Gets the value, using the cached value if available or reading from storage if not.

This prioritizes the cached value to avoid disk reads, updating the cache when a read from storage is necessary.

Implementation

@override

/// Gets the value, using the cached value if available or reading from storage if not.
///
/// This prioritizes the cached value to avoid disk reads, updating the cache
/// when a read from storage is necessary.
Future<T?> getValue(SharedPreferencesAsync prefs) async {
  if (_cachedValue != null) return _cachedValue;
  return _cachedValue ??= await super.getValue(prefs);
}