deleteItem method
Implementation
Future<bool> deleteItem(itemId, {bool log = true}) async {
var collectionData = await get();
if (_isMap(collectionData)) {
if ((collectionData as Map).containsKey(itemId)) {
collectionData.remove(itemId);
} else {
throw const StorageDatabaseException('Undefined item id');
}
} else if (_isList(collectionData)) {
if (itemId >= 0 && (collectionData as List).length >= itemId) {
collectionData.removeAt(itemId);
} else {
throw const StorageDatabaseException('Undefined item id');
}
} else {
throw const StorageDatabaseException(
'This Collection doesn\'t support collections',
);
}
await set(collectionData, keepData: false);
if (log) {
for (String streamId in storageListeners.getPathStreamIds(path)) {
if (storageListeners.hasStreamId(path, streamId)) {
storageListeners.setDate(path, streamId);
}
}
}
return true;
}