canVersionUpdate property

bool get canVersionUpdate

Implementation

bool get canVersionUpdate {
  // assume version strings can be of the form aa.bb.cc
  // this implementation correctly compares local 1.8.0 to store 1.7.4
  try {
    final currentFields = currentVersion.split('.');
    final storeFields = storeVersion.split('.');
    String currentPad = '';
    String storePad = '';
    for (int i = 0; i < storeFields.length; i++) {
      currentPad = currentPad + currentFields[i].padLeft(3, '0');
      storePad = storePad + storeFields[i].padLeft(3, '0');
    }

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