checkNumber method

bool checkNumber(
  1. String? ch
)

Implementation

bool checkNumber(String? ch) {
  if (ch == '+' || ch == '-') {
    token = ch;
    ch = peekChar();
    while (
        (ch?.compareTo('0') ?? -1) >= 0 && (ch?.compareTo('9') ?? 1) <= 0) {
      token = token! + ch!;
      index++;
      ch = peekChar();
    }
    if (token!.length == 1) {
      throw UcumException(
          "Error processing unit '$source': unexpected character '$ch' at position $start: a + or - must be followed by at least one digit");
    }
    type = TokenType.number;
    return true;
  }
  return false;
}