deleteItem method

Future<void> deleteItem(
  1. Map<String, dynamic> itemToDelete, {
  2. List<JsendStatusHandler>? statusHandlers,
})

Implementation

Future<void> deleteItem(Map<String, dynamic> itemToDelete,
    {List<JsendStatusHandler>? statusHandlers}) async {
  if (!itemToDelete.containsKey('_id')) {
    throw Exception('_id not found in given input item.');
  }
  (await jsendResponse.fromAPIRequest(
      APIRequest(
        path: endpoint + '/' + itemToDelete['_id'],
        method: 'DELETE',
      ), onSuccess: (jsendResponse res) {
    if (_loadedAll) {
      _allFromServer.remove(_getLoadedItemByID(itemToDelete['_id']));
    }
  }, statusHandlers: statusHandlers));
}