fetchUpdate static method
Downloads patch assets in the background, reporting fine-grained progress.
Implementation
static Future<bool> fetchUpdate({
void Function(double progress)? onProgress,
}) async {
final manifest = _pendingStagedManifest;
if (manifest == null) {
logger.warn('BloomUpdates: fetchUpdate called but no update is available.');
return false;
}
_isDownloading.value = true;
_downloadProgress.value = 0.0;
_error.value = null;
try {
final success = await _adapter.downloadPatchAssets(
manifest: manifest,
onProgress: (p) {
_downloadProgress.value = p;
onProgress?.call(p);
},
);
if (success) {
_isDownloading.value = false;
_isReady.value = true;
_downloadProgress.value = 1.0;
logger.info('BloomUpdates: Patch "${manifest.id}" successfully staged and ready for reload.');
return true;
} else {
throw StateError('Patch download verification failed.');
}
} catch (e, st) {
logger.error('BloomUpdates: Download failed: $e', e, st);
_error.value = e;
_isDownloading.value = false;
_isReady.value = false;
return false;
}
}