checkForUpdates method
void
checkForUpdates()
Implementation
void checkForUpdates() async {
if (status == UpgradeStatus.loadingLocalConfig || status == UpgradeStatus.dismissed) return;
state.updateUpgradeStatus(status: UpgradeStatus.checking);
Client().get(
Uri.parse(_url),
headers: {'Content-Type': 'application/json;charset=utf-8'},
).then((response) {
if (response.statusCode != 200) {
state.updateUpgradeStatus(status: UpgradeStatus.error);
debugPrint("[UpgradeManager] Download Appcast from $_url error.");
return;
}
final appcast = Appcast.fromJson(List<Map<String, dynamic>>.from(json.decode(response.body)));
final best = appcast.best();
if (best != null) {
state.updateLatestVersion(version: best);
initInstallers();
nextInstaller();
} else {
state.updateUpgradeStatus(status: UpgradeStatus.upToDate);
}
}).catchError((_) {
state.updateUpgradeStatus(status: UpgradeStatus.error);
});
}