setItems<T extends StorableModel> method
Creates or updates multiple items in a specified collection.
This method retrieves the current data for the given tag,
updates existing items, or adds new ones from the provided items list.
The updated data is then saved to persistent storage.
Parameters:
tag: A unique identifier for the collection where the items are stored.items: A list of objects of typeTthat extends StorableModel, representing the items to be created or updated.
Returns:
- A Future that completes when all items are successfully stored.
Implementation
Future<void> setItems<T extends StorableModel>(
final String tag,
final List<T> items,
) async {
final Map<String, dynamic> data = await _loadData(tag);
for (final T item in items) {
data[item.id] = item.toJson();
}
await _saveData(tag, data);
}