checkAppVersion function

VersionCheck checkAppVersion({
  1. required AppInfo appInfo,
  2. VersionCheckInfo? versionInfo,
})

Implementation

VersionCheck checkAppVersion({
  required AppInfo appInfo,
  VersionCheckInfo? versionInfo,
}) {
  if (kIsWeb) return VersionCheck.noCheck(appInfo);
  //Get Current installed version of app

  final currentVersion = appInfo.appVersion;
  try {
    final forceVersion = versionInfo!.forceUpgradePrior!;
    final warnVersion = versionInfo.warnUpgradePrior;

    if (forceVersion > currentVersion) {
      return VersionCheck(
          appInfo: appInfo,
          result: VersionCheckResult.force,
          expectedVersion: forceVersion);
    } else if (warnVersion! > currentVersion) {
      return VersionCheck(
          appInfo: appInfo,
          result: VersionCheckResult.warn,
          expectedVersion: warnVersion);
    } else {
      return VersionCheck(
          appInfo: appInfo,
          result: VersionCheckResult.ok,
          expectedVersion: warnVersion);
    }
  } catch (exception) {
    _log.info('Unable to fetch remote config. Cached or default values will be '
        'used: $exception');

    return VersionCheck(appInfo: appInfo, result: VersionCheckResult.error);
  }
}