unit top-level property

Parser<String> unit
final

Implementation

final Parser<String> unit =
    (pluralDateTimePrecision |
            dateTimePrecision |
            STRING
                .where((value) {
                  return UcumService().validate(value.value) == null;
                })
                .trim()
                .map((value) => value.value))
        .flatten()
        .map((value) {
          if (value.startsWith("'")) {
            value = value.substring(1, value.length - 1);
          }
          if (value.endsWith("'")) {
            value = value.substring(0, value.length - 1);
          }
          return value;
        });