getAppVersion method

Future<bool> getAppVersion()

Implementation

Future<bool> getAppVersion() async {
  if (_appVersion.isEmpty) {
    _appVersion = '0';
  }

  final oldCode = '$_appCode.$_appVersion';
  final newCode =
      '${Cav.instance.appFile.newAppCode!}.${Cav.instance.appFile.newAppVersion!}';

  final oldVersionParts = oldCode.split('.').map(int.parse).toList();
  final newVersionParts = newCode.split('.').map(int.parse).toList();

  for (var i = 0; i < oldVersionParts.length; i++) {
    if (oldVersionParts[i] < newVersionParts[i]) {
      return true;
    } else if (oldVersionParts[i] > newVersionParts[i]) {
      return false;
    }
  }

  return false;
}