clearAll method
Future<void>
clearAll({
- required bool isSingle,
- required bool isRange,
- required ProductContentModel data_,
Implementation
Future<void> clearAll({
required bool isSingle,
required bool isRange,
required ProductContentModel data_,
}) async {
if (isSingle) {
ProductContentModel? scannedProduct;
for (final data in productDataScannedList) {
if (data.productCode == data_.productCode) {
scannedProduct = data;
break;
}
}
if (scannedProduct != null) {
scannedProduct.iccidList?.forEach((element) {
scannedIccidList.removeWhere((data) => data == element.iccid);
scannedProduct!.scannedserialNums!
.removeWhere((data) => data == int.parse(element.iccid!));
});
ProductContentModel updatedProduct = scannedProduct.copyWith(
iccidList: [],
scannedQty: scannedProduct.scannedserialNums!.length,
scannedserialNums: scannedProduct.scannedserialNums);
var temp = productDataScannedList;
int index = temp.indexOf(scannedProduct);
temp[index] = updatedProduct;
productDataScannedList = temp;
}
} else if (isRange) {
ProductContentModel? scannedProduct;
for (final data in productDataScannedList) {
if (data.productCode == data_.productCode) {
scannedProduct = data;
break;
}
}
if (scannedProduct != null) {
scannedProduct.rangeList?.forEach((element) {
element.iccidList!.forEach((range) {
scannedIccidList.removeWhere((data) => data == range.iccid);
scannedProduct!.scannedserialNums!
.removeWhere((data) => data == int.parse(range.iccid!));
});
});
ProductContentModel updatedProduct = scannedProduct.copyWith(
rangeList: [],
scannedQty: scannedProduct.scannedserialNums!.length,
scannedserialNums: scannedProduct.scannedserialNums);
var temp = productDataScannedList;
int index = temp.indexOf(scannedProduct);
temp[index] = updatedProduct;
productDataScannedList = temp;
}
}
}