hasEmptyOrNullResources method

bool hasEmptyOrNullResources(
  1. List<ProductVariantModel?> deliveredProducts
)

Implementation

bool hasEmptyOrNullResources(List<ProductVariantModel?> deliveredProducts) {
  final Map<String?, List<ProductVariantModel?>> groupedVariants = {};
  if (deliveredProducts.isNotEmpty) {
    for (final variant in deliveredProducts) {
      final productId = variant?.productId;
      if (productId != null) {
        groupedVariants.putIfAbsent(productId, () => []);
        groupedVariants[productId]?.add(variant);
      }
    }
    bool hasDuplicateProductIdOrNoProductId =
        deliveredProducts.any((ele) => ele?.productId == null);

    return hasDuplicateProductIdOrNoProductId;
  }

  return true;
}