parseNumber static method

double parseNumber(
  1. String string
)

Implementation

static double parseNumber(String string) {
  if (string.endsWith("K") ||
      string.endsWith("M") ||
      string.endsWith("B") ||
      string.endsWith("T")) {
    final number = double.parse(string.substring(0, string.length - 1));
    final multiplier = string.substring(string.length - 1);

    return {
          "K": number * 1000,
          "M": number * 1000 * 1000,
          "B": number * 1000 * 1000 * 1000,
          "T": number * 1000 * 1000 * 1000 * 1000,
        }[multiplier] ??
        double.nan;
  } else {
    return double.parse(string);
  }
}