checkForUpdate static method
Check if a newer OTA code-push patch is available on the active channel.
Implementation
static Future<bool> checkForUpdate({
Future<BloomOtaPatch?> Function()? customChecker,
}) async {
_setStatus(BloomOtaStatus.checkingForUpdate);
try {
if (customChecker != null) {
final patch = await customChecker();
if (patch != null && (_currentPatchNumber == null || patch.patchNumber > _currentPatchNumber!)) {
_availablePatch = patch;
_setStatus(BloomOtaStatus.updateAvailable);
return true;
}
_setStatus(BloomOtaStatus.upToDate);
return false;
}
if (_updater.isAvailable) {
final status = await _updater.checkForUpdate();
if (status == UpdateStatus.outdated) {
_setStatus(BloomOtaStatus.updateAvailable);
return true;
} else if (status == UpdateStatus.restartRequired) {
_setStatus(BloomOtaStatus.updateReady);
return true;
} else {
_setStatus(BloomOtaStatus.upToDate);
return false;
}
}
// If running in development without Shorebird engine
_setStatus(BloomOtaStatus.upToDate);
return false;
} catch (e) {
logger.error('BloomOTA check failed: $e');
_setStatus(BloomOtaStatus.error);
return false;
}
}