setString method

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

Stores a string value in SharedPreferences.

  • key: The key for the string value to be stored.
  • value: The string value to store.

Implementation

Future<void> setString(String key, String value) async {
  await ensureSharedPrefIsInitialized();
  if (stringKeys.containsKey(key)) {
    await prefs.setString(key, value);
  } else {
    throw Exception("Key '$key' is not implemented as string.");
  }
}