checkBrackets method

bool checkBrackets(
  1. String? ch,
  2. bool inBrackets
)

Implementation

bool checkBrackets(String? ch, bool inBrackets) {
  if (ch == '[') {
    if (inBrackets) {
      throw UcumException(
          "Error processing unit '$source': Nested [ at position $start");
    } else {
      return true;
    }
  }
  if (ch == ']') {
    if (!inBrackets) {
      throw UcumException(
          "Error processing unit '$source': ] without [ at position $start");
    } else {
      return false;
    }
  }
  return inBrackets;
}