convertUnit method

  1. @visibleForTesting
double convertUnit(
  1. {required MealRecordNutrientType type,
  2. required double fromValue,
  3. required String fromUnit}
)

単位換算する 表示用単位と同一であればそのままの値を返す 定義のない単位は0を返す

Implementation

@visibleForTesting
double convertUnit({
  required MealRecordNutrientType type,
  required double fromValue,
  required String fromUnit,
}) {
  switch (type) {
    // 塩分の単位換算
    case MealRecordNutrientType.natrium:
      return convertNatriumUnit(
        fromValue: fromValue,
        fromUnit: fromUnit,
      );

    // 水分の単位換算
    case MealRecordNutrientType.water:
      return convertWaterUnit(
        fromValue: fromValue,
        fromUnit: fromUnit,
      );
  }
}