getNutrient static method

Nutrient? getNutrient(
  1. OrderedNutrient orderedNutrient
)

Returns the Nutrient that matches the orderedNutrient.

Special case: energy is considered as energyKJ

Implementation

static Nutrient? getNutrient(OrderedNutrient orderedNutrient) {
  if (orderedNutrient.id == 'energy') {
    return Nutrient.energyKJ;
  }
  return orderedNutrient.nutrient;
}