setBool method

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

Stores a boolean value in SharedPreferences.

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

Implementation

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