Flutter APP の新バージョン検出バージョン番号の比較を記録する

コードは次のとおりです。コピーを直接使用できます。

/**
 * newVersion 新しいバージョン番号
 * 古い古いバージョン番号
 * */
static bool isUpdateVersion(String newVersion, String old) {
  if (newVersion == null || newVersion.isEmpty || old == null || old.isEmpty)
    false を返します。
  int newVersionInt、oldVersion;
  var newList = newVersion.split('.');
  var oldList = old.split('.');
  if (newList.length == 0 || oldList.length == 0) {
    false を返します。
  }
  for (int i = 0; i < newList.length; i++) {
    newVersionInt = int.parse(newList[i]);
    oldVersion = int.parse(oldList[i]);
    if (newVersionInt > oldVersion) {
      true を返します。
    else if (newVersionInt < oldVersion) {
      false を返します。
    }
  }
  false を返します。
}

Guess you like

Origin blog.csdn.net/wxx314165038/article/details/120966580