isUpdateAvailable method

bool isUpdateAvailable()

Implementation

bool isUpdateAvailable() {
  if (debugLogging) {
    if (kDebugMode) {
      print('hcUpgrade: appStoreVersion: $_appStoreVersion');
      print('hcUpgrade: installedVersion: $_installedVersion');
      print('hcUpgrade: minAppVersion: $minAppVersion');
    }
  }
  if (_appStoreVersion == null || _installedVersion == null) {
    if (debugLogging){ if (kDebugMode) {
      print('hcUpgrade: isUpdateAvailable: false');
    }}
    return false;
  }

  try {
    final appStoreVersion = Version.parse(_appStoreVersion!);
    final installedVersion = Version.parse(_installedVersion!);

    final available = appStoreVersion > installedVersion;
    _updateAvailable = available ? _appStoreVersion : null;
  } on Exception catch (e) {
    if (debugLogging) {
      if (kDebugMode) {
        print('hcUpgrade: isUpdateAvailable: $e');
      }
    }
  }
  final isAvailable = _updateAvailable != null;
  if (debugLogging){ if (kDebugMode) {
    print('hcUpgrade: isUpdateAvailable: $isAvailable');
  }}
  return isAvailable;
}