checkForUpdate method
Check for updates.
silent - If true, no UI feedback is shown for "no update" or errors.
Implementation
Future<UpdateCheckResult> checkForUpdate({bool silent = true}) async {
if (config.isDisabled) {
config.log('Version update service is disabled');
if (!silent) {
_showDisabledSnackbar();
}
return const UpdateCheckDisabled();
}
if (isCheckingForUpdate.value) {
return const UpdateCheckError('Already checking');
}
isCheckingForUpdate.value = true;
try {
final result = await _core.checkForUpdate();
lastCheckResult.value = result;
switch (result) {
case UpdateAvailable(versionInfo: final info):
_showUpdateAvailableUI(info);
case NoUpdateAvailable():
if (!silent) {
_showNoUpdateSnackbar();
}
case UpdateCheckError(message: final msg):
if (!silent) {
_showErrorSnackbar('Update Check Failed', msg);
}
case UpdateCheckDisabled():
if (!silent) {
_showDisabledSnackbar();
}
}
return result;
} finally {
isCheckingForUpdate.value = false;
}
}