clearTag method
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: AStringrepresenting 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
SharedPreferenceswill 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>{});
}