hasDuplicateResources method
bool
hasDuplicateResources(
- List<ProductVariantModel?> deliveredProducts,
- FormGroup form
)
Implementation
bool hasDuplicateResources(
List<ProductVariantModel?> deliveredProducts, FormGroup form) {
final resourceDeliveredArray =
form.control(_resourceDeliveredKey) as FormArray;
final Set<String?> uniqueProductIds = {};
for (int i = 0; i < resourceDeliveredArray.value!.length; i++) {
final productId = deliveredProducts[i]?.id;
if (productId != null) {
if (uniqueProductIds.contains(productId)) {
// Duplicate found
return true;
} else {
uniqueProductIds.add(productId);
}
}
}
return false;
}