composeCanonical method

String composeCanonical(
  1. Canonical can, [
  2. bool value = true
])

Implementation

String composeCanonical(Canonical can, [bool value = true]) {
  final StringBuffer buffer = StringBuffer();
  if (value) {
    buffer.write(can.value.asUcumDecimal());
  }
  bool first = true;
  for (final CanonicalUnit c in can.units) {
    if (!first) {
      buffer.write('.');
    }
    first = false;
    buffer.write(c.base.code);
    if (c.exponent != 1) {
      buffer.write(c.exponent);
    }
  }
  return buffer.toString();
}