haveNewVersion static method

bool haveNewVersion(
  1. String newVersion,
  2. String old
)

Implementation

static bool haveNewVersion(String newVersion, String old) {
  if (newVersion.isEmpty || old.isEmpty) {
    return false;
  }
  int newVersionInt, oldVersion;
  var newList = newVersion.split('.');
  var oldList = old.split('.');
  if (newList.isEmpty || oldList.isEmpty) {
    return false;
  }
  for (int i = 0; i < newList.length; i++) {
    newVersionInt = int.parse(newList[i]);
    oldVersion = int.parse(oldList[i]);
    if (newVersionInt > oldVersion) {
      return true;
    } else if (newVersionInt < oldVersion) {
      return false;
    }
  }

  return false;
}