bestItem method
Returns the latest item in the Appcast based on OS, OS version, and app version.
Implementation
AppCastItem? bestItem() {
if (items == null) {
return null;
}
AppCastItem? bestItem;
for (var item in items!) {
if (item.hostSupportsItem(
osVersion: osVersionString, currentPlatform: hcUpgradeOS.current)) {
if (bestItem == null) {
bestItem = item;
} else {
try {
final itemVersion = Version.parse(item.versionString!);
final bestItemVersion = Version.parse(bestItem.versionString!);
if (itemVersion > bestItemVersion) {
bestItem = item;
}
} on Exception catch (e) {
if (kDebugMode) {
print('hcUpgrade: bestItem invalid version: $e');
}
}
}
}
}
return bestItem;
}