setValue method

Future<bool> setValue(
  1. SharedPreferences prefs,
  2. T value
)

Saves a new value to SharedPreferences and updates the cache.

Updates the cache only if the save operation succeeds. Returns a Future<bool> indicating whether the operation was successful.

Implementation

Future<bool> setValue(SharedPreferences prefs, T value) async {
  final result = await _setter(prefs, key, value);
  if (result) _cachedValue = value;
  return result;
}