removeItems method

Future<void> removeItems(
  1. String tag,
  2. List<String> ids
)

Deletes multiple items from the data store associated with a specific tag.

This method retrieves the data corresponding to the provided tag, iterates over the list of ids to remove each matching entry, and then saves the updated data back to the storage.

Parameters:

  • tag: A String representing the category or group of data to target.
  • ids: A List<String> containing unique identifiers of the items to be deleted.

Returns:

  • A Future<void> indicating the completion of the delete operation.

Throws:

  • Any errors encountered during data loading or saving will propagate.

Implementation

Future<void> removeItems(final String tag, final List<String> ids) async {
  final Map<String, dynamic> data = await _loadData(tag);
  for (int i = 0; i < ids.length; i++) {
    final String id = ids[i];
    data.remove(id);
  }
  await _saveData(tag, data);
}