clear method

Future<bool> clear()

Completes with true once the user preferences for the app has been cleared.

Implementation

Future<bool> clear() {
  _preferenceCache.clear();
  if (_prefixHasBeenChanged) {
    try {
      return _store.clearWithParameters(
        ClearParameters(
          filter: PreferencesFilter(
            prefix: _prefix,
            allowList: _allowList,
          ),
        ),
      );
    } catch (e) {
      // Catching and clarifying UnimplementedError to provide a more robust message.
      if (e is UnimplementedError) {
        throw UnimplementedError('''
This implementation of Shared Preferences doesn't yet support the setPrefix method.
Either update the implementation to support setPrefix, or do not call setPrefix.
      ''');
      } else {
        rethrow;
      }
    }
  }
  return _store.clear();
}