getUriProductHelper method

  1. @protected
Future<UriProductHelper> getUriProductHelper(
  1. LocalDatabase localDatabase
)

Implementation

@protected
Future<UriProductHelper> getUriProductHelper(
  LocalDatabase localDatabase,
) async {
  // in case the product type evolved (very rare cases), we need to check it
  // and use the correct product type instead.
  final DaoProduct daoProduct = DaoProduct(localDatabase);
  final Product? product = await daoProduct.get(barcode);
  final ProductType? databaseProductType = product?.productType;
  final ProductType bestProductType = databaseProductType ?? productType;
  if (databaseProductType != null && databaseProductType != productType) {
    Logs.w(
      'Product type change for $barcode'
      ': $productType expected'
      ', $databaseProductType from database',
    );
  }
  return ProductQuery.getUriProductHelper(productType: bestProductType);
}