parseVersion static method

double parseVersion(
  1. String version, [
  2. String separator = '.'
])

Parses the given version into a double.

Implementation

static double parseVersion(String version, [String separator='.']) {
  try {
    int j = version.indexOf(separator);
    if (j >= 0) {
      final k = version.indexOf(separator, ++j);
      if (k >= 0)
        version = version.substring(0, k);
      if (version.length == j + 1) //only one decimal, e.g., 12.3
        version = version.substring(0, j) + "0" + version.substring(j);
      if (separator != '.')
        version = version.replaceAll(separator, '.');
    }
    return double.parse(version);
  } catch (e) {
    return 1.0; //ignore it
  }
}