hostSupportsItem method

bool hostSupportsItem({
  1. String? osVersion,
  2. String? currentPlatform,
})

Implementation

bool hostSupportsItem({String? osVersion, String? currentPlatform}) {
  var supported = true;
  if (osString != null && osString!.isNotEmpty) {
    final platformEnum = 'TargetPlatform.' + osString!;
    currentPlatform = currentPlatform == null
        ? defaultTargetPlatform.toString()
        : 'TargetPlatform.' + currentPlatform;
    supported = platformEnum.toLowerCase() == currentPlatform.toLowerCase();
  }

  if (supported && osVersion != null && osVersion.isNotEmpty) {
    var osVersionValue;
    try {
      osVersionValue = Version.parse(osVersion);
    } catch (e) {
      print('appcast.hostSupportsItem: invalid osVerion: $e');
      return false;
    }
    if (maximumSystemVersion != null) {
      final maxVersion = Version.parse(maximumSystemVersion!);
      if (osVersionValue > maxVersion) {
        supported = false;
      }
    }
    if (supported && minimumSystemVersion != null) {
      final minVersion = Version.parse(minimumSystemVersion!);
      if (osVersionValue < minVersion) {
        supported = false;
      }
    }
  }
  return supported;
}