convertTo method

ValidatedQuantity convertTo(
  1. String newCode
)

Implementation

ValidatedQuantity convertTo(String newCode) {
  if (UcumService().isComparable(unit, newCode)) {
    final UcumDecimal value =
        UcumService().convert(this.value, unit, newCode);
    return ValidatedQuantity(value: value, unit: newCode);
  } else {
    throw UcumException('Cannot convert $this to $newCode');
  }
}