getExpressionValue static method

String getExpressionValue(
  1. bool isNumber
)

Implementation

static String getExpressionValue(bool isNumber) {
  String exprValue = "";
  String exponentValue = "";
  bool foundExponent = false;

  if (!isNumber) {
    if (inputString[index] != '"') {
      exprValue = look;
      index++;
    }

    int contentLength = inputString.indexOf('"', index);
    exprValue += inputString.substring(index, contentLength);
    index = contentLength;

    exprValue = DynamoCommons.decodeUnicodeCharacters(exprValue);
  } else {
    if (DynamoCommons.isDigit(look) || look == "-") {
      exprValue = look;

      while ((index <= inputString.length - 1) &&
          (DynamoCommons.isDigit(inputString[index]) ||
              inputString[index] == '.' ||
              inputString[index] == 'E')) {
        if (inputString[index] == 'E') {
          foundExponent = true;
          index++;
        }

        if (foundExponent) {
          exponentValue += inputString[index++];
        } else {
          exprValue += inputString[index++];
        }
      }
    }

    if ((foundExponent) && (DynamoCommons.isDigitSequence(exponentValue))) {
      exprValue =
          (double.parse(exprValue) * pow(10, double.parse(exponentValue)))
              .toString();
    }
  }

  read(indexPos: index);

  return exprValue;
}