clear method

Future<bool> clear()

Clear, or in other words, remove, the value. Effectively sets the key to a null value. After removing a value, the Preference will emit defaultValue once.

Returns true if the clear operation was successful, otherwise returns false.

Implementation

Future<bool> clear() async {
  if (key == $$_getKeysKey) {
    throw UnsupportedError(
      'clear() not supported for Preference with a null key.',
    );
  }

  return _updateAndNotify(_preferences.remove(key));
}