readBool method

Future<bool> readBool(
  1. String key, {
  2. bool defaultValue = false,
})

Reads a boolean value from the store under the given key.

Implementation

Future<bool> readBool(String key, {bool defaultValue = false}) async {
  if (useSecure) {
    final val = await _secureStorage.read(key: key);
    if (val == null) return defaultValue;
    return val.toLowerCase() == 'true';
  } else {
    final prefs = await SharedPreferences.getInstance();
    return prefs.getBool(key) ?? defaultValue;
  }
}