clearTag method

Future<void> clearTag(
  1. String tag
)

Clears all data associated with the specified tag.

This method removes the stored data for the provided tag from both persistent storage (using SharedPreferences) and the in-memory cache. It also updates the corresponding stream controller with an empty map, ensuring any listeners are notified of the cleared state.

Parameters:

  • tag: A String representing the category or group of data to clear.

Returns:

  • A Future<void> that completes when the data is successfully cleared.

Throws:

  • Any errors encountered while accessing or modifying SharedPreferences will propagate.

Implementation

Future<void> clearTag(final String tag) async {
  final SharedPreferences prefs = await _prefs;
  await prefs.remove(tag);
  _cache.remove(tag);
  _getController(tag).add(<String, dynamic>{});
}