unitConvertedQuantity property

double unitConvertedQuantity

定義した単位に換算した栄養素の量

Implementation

double get unitConvertedQuantity {
  // 定義した栄養素タイプ以外は0を返す
  if (!MealRecordNutrientType.values.any((e) => e.code == name)) {
    return 0;
  }
  final type = MealRecordNutrientType.fromCode(name);

  final convertedValue = convertUnit(
    type: type,
    fromValue: quantity,
    fromUnit: unit,
  );

  return convertedValue;
}