void updateApp() async {
updateStatus.value = 'updating...';
String remoteUpdateFolder =
ProjectManager().appInitModel?.appUpdates?.downloadUrl ?? '';
if (remoteUpdateFolder.isEmpty) {
closeDialog();
return;
}
List<FileHashModel?> changedFiles = await updater.prepareUpdateApp(
remoteUpdateFolder: remoteUpdateFolder,
);
if (changedFiles.isNotEmpty) {
final progressStream = await updater.updateApp(
remoteUpdateFolder: remoteUpdateFolder,
changedFiles: changedFiles,
);
progressStream.listen(
(progress) {
logger.i('download progress: ${progress.receivedBytes}/${progress.totalBytes} KB');
updateStatus.value = 'downloading...';
updateProgress.value = progress.receivedBytes / progress.totalBytes;
},
onDone: () {
updateStatus.value = 'restart...';
updateProgress.value = 1.0;
updater.restartApp();
},
onError: (error) {
updateStatus.value = 'error: $error';
closeDialog();
},
);
} else {
logger.e('empty update');
closeDialog();
}
}
I didn't see any relevant documents or source code using prepareUpdateApp. Although it causes errors when overriding installation in the development environment and makes the application unable to open, in the release environment, it seems to be able to perform the override normally.
I don't know if it can be used.
I hope to receive a reply from the author.
thanks.
I didn't see any relevant documents or source code using prepareUpdateApp. Although it causes errors when overriding installation in the development environment and makes the application unable to open, in the release environment, it seems to be able to perform the override normally.
I don't know if it can be used.
I hope to receive a reply from the author.
thanks.