removeImages static method

void removeImages(
  1. Product product,
  2. OpenFoodFactsLanguage? language
)

Reduces the set of images of the product depending on the given language.

Implementation

static void removeImages(Product product, OpenFoodFactsLanguage? language) {
  if (product.selectedImages == null) {
    return;
  }

  for (var field in ImageField.values) {
    if (product.selectedImages!
        .any((i) => i.field == field && i.language == language)) {
      product.selectedImages!
          .removeWhere((i) => i.field == field && i.language != language);
    }
  }
}