isMinVersion method

bool isMinVersion(
  1. String minVersion
)

Implementation

bool isMinVersion(String minVersion) {
  // this implementation correctly compares minimum version to current version
  try {
    final minimumFields = minVersion.split('+')[0].split('.');
    final currentFields = currentVersion.split('.');
    String currentPad = '';
    String minimumPad = '';
    for (int i = 0; i < currentFields.length; i++) {
      currentPad = currentPad + currentFields[i].padLeft(3, '0');
      minimumPad = minimumPad + minimumFields[i].padLeft(3, '0');
    }

    if (currentPad.compareTo(minimumPad) < 0)
      return true;
    else
      return false;
  } catch (e) {
    return currentVersion.compareTo(minVersion).isNegative;
  }
}