putAll method

Future<void> putAll(
  1. Iterable<Product> products,
  2. OpenFoodFactsLanguage language, {
  3. required ProductType productType,
})

Replaces products in database

Implementation

Future<void> putAll(
  Iterable<Product> products,
  OpenFoodFactsLanguage language, {
  required ProductType productType,
}) async {
  for (final Product product in products) {
    // in case the server product has no product type, which shouldn't happen
    // in the future
    product.productType ??= productType;
  }
  await localDatabase.database.transaction(
    (Transaction transaction) async =>
        _bulkReplaceLoop(transaction, products, language, productType),
  );
}