flutter 判断iOS的版本号是否大于13,大于才显示苹果登录

int compareVersionNumbers(String version1, String version2) {
  List<int> v1 = version1.split('.').map(int.parse).toList();
  List<int> v2 = version2.split('.').map(int.parse).toList();

  int minLength = v1.length < v2.length ? v1.length : v2.length;

  for (int i = 0; i < minLength; i++) {
    if (v1[i] < v2[i]) {
      return -1; // version1 < version2
    } else if (v1[i] > v2[i]) {
      return 1; // version1 > version2
    }
  }

  if (v1.length < v2.length) {
    return -1; // version1 < version2
  } else if (v1.length > v2.length) {
    return 1; // version1 > version2
  }

  return 0; // version1 == version2
}

void main() {
  String version1 = "16.2.1";
  String version2 = "13.3.1";

  int result = compareVersionNumbers(version1, version2);

  if (result > 0) {
    print("$version1 大于 $version2");
  } else if (result < 0) {
    print("$version1 小于 $version2");
  } else {
    print("$version1 等于 $version2");
  }
}

你可能感兴趣的:(flutter,ios,flutter,ios)