checkNow method
- bool ignoreSkips = false,
Runs a version check and updates state.
Implementation
Future<void> checkNow({bool ignoreSkips = false}) async {
final generation = ++_generation;
_set(const PrismUpdateChecking());
try {
final latest = await _source.fetchLatest();
if (generation != _generation) return;
final result = policy.evaluate(currentVersion, latest);
final remote = switch (_source) {
RemoteUpdateSource remote => remote,
_ => null,
};
final downloadUrl = remote?.downloadUrlFor(platformInfo.key);
final notes = remote?.notesFor(result.latest ?? currentVersion);
final PrismUpdateState next;
if (result.isUpdateAvailable) {
final available = PrismUpdateAvailable(
current: currentVersion,
result: result,
downloadUrl: downloadUrl,
notes: notes,
);
final latestVersion = result.latest;
final skipped =
!ignoreSkips &&
!result.isForced &&
latestVersion != null &&
await (_skipStore?.isSkipped(latestVersion) ?? Future.value(false));
next = skipped ? PrismUpdateSkipped(available: available) : available;
} else {
next = PrismUpdateUpToDate(latest: result.latest);
}
_set(next);
} catch (error, stackTrace) {
if (generation != _generation) return;
_set(PrismUpdateFailure(error, stackTrace));
}
}