getNutrient function

Nutrient getNutrient(
  1. OrderedNutrient orderedNutrient
)

Implementation

Nutrient getNutrient(OrderedNutrient orderedNutrient) {
  if (orderedNutrient.nutrient != null) {
    return orderedNutrient.nutrient!;
  }
  if (orderedNutrient.id == 'energy') {
    return Nutrient.energyKJ;
  }
  throw Exception('unknown nutrient for "${orderedNutrient.id}"');
}