deleteProduct method

Future<void> deleteProduct(
  1. ProductContentModel data_
)

Implementation

Future<void> deleteProduct(ProductContentModel data_) async {
  ProductContentModel? scannedProduct;
  for (final data in productDataScannedList) {
    if (data.productCode == data_.productCode) {
      scannedProduct = data;
      break;
    }
  }
  if (currentScan == ScanType.sellThru ||
      currentScan == ScanType.collectStock) {
    if (scannedProduct != null) {
      scannedProduct.iccidList?.forEach((element) {
        scannedIccidList.removeWhere((data) => data == element.iccid);
      });
      ProductContentModel updatedProduct = scannedProduct.copyWith(
          iccidList: [], rangeList: [], scannedQty: 0, scannedserialNums: []);

      var temp = productDataScannedList;
      int index = temp.indexOf(scannedProduct);
      temp[index] = updatedProduct;
      productDataScannedList = temp;
      searchedScannedList = productDataScannedList;
    }
  } else if (currentScan == ScanType.spotSellThru) {
    if (scannedProduct != null) {
      var temp = productDataScannedList;
      int index = temp.indexOf(scannedProduct);
      temp.removeAt(index);
      productDataScannedList = temp;
    }
  }
}