getProductNameBrandQuantity method
Returns a combo of best product name, first brand and quantity.
cf. openfoodfacts-server/lib/ProductOpener/Products.pm
Implementation
String getProductNameBrandQuantity(
final OpenFoodFactsLanguage language,
final String separator,
) {
final String productNameBrand = getProductNameBrand(language, separator);
if (quantity?.isNotEmpty != true) {
return productNameBrand;
}
if (productNameBrand.contains(quantity!)) {
return productNameBrand;
}
// quantity: put non breaking spaces between numbers and units
return '$productNameBrand$separator${quantity!.replaceAll(' ', '\u{00A0}')}';
}