setString method

Future<void> setString(
  1. String key,
  2. String value
)

Saves a string value to the cache and platform.

Note: Due to limitations on some platforms, values cannot start with the following:

  • 'VGhpcyBpcyB0aGUgcHJlZml4IGZvciBhIGxpc3Qu'

Throws an ArgumentError if key is not in this instance's filter.

Implementation

Future<void> setString(String key, String value) async {
  if (!_isValidKey(key)) {
    throw ArgumentError(
        '$key is not included in the PreferencesFilter allowlist');
  }
  _cache[key] = value;
  return _platformMethods.setString(key, value);
}