containsKey method

bool containsKey(
  1. dynamic key
)

Checks if a value exists in the shared preferences based on the provided key.

Returns true if the value exists, otherwise returns false.

The key parameter represents the key associated with the value to check in shared preferences.

Example:

bool exists = SimpleSharedPref().containsKey('username');

Implementation

bool containsKey(dynamic key) {
  try {
    return _preferences!.containsKey(key.toString());
  } catch (e) {
    _logException('Error while checking existence in shared preferences',
        error: e);
  }
  return false;
}