getNutritionValues method
- PerSize perSize
Returns the packaging as sold values for perSize.
Old nutriments values are converted, and overridden by the new ones.
Implementation
// TODO(UrbanFercec): also read the manufacturer, per 100ml and per serving sets.
Map<Nutrient, NutritionValue> getNutritionValues(PerSize perSize) {
final Map<Nutrient, NutritionValue> result = <Nutrient, NutritionValue>{};
<Nutrient, NutritionValue>{
..._getOldNutritionValues(perSize),
...?NutritionHelper()
.getNutritionSet(
NutritionHelper().getInputSets(this) ?? <NutritionSet>[],
NutritionSetKey(
source: NutritionSetKey.sourcePackaging,
preparation: NutritionSetKey.preparationAsSold,
perSize: perSize,
),
)
?.nutritionValues,
}.forEach((Nutrient nutrient, NutritionValue nutritionValue) {
final NutritionValue? numberValue = _getNumber(nutritionValue);
if (numberValue != null) {
result[nutrient] = numberValue;
}
});
return result;
}