downloadUpdate method
Implementation
Future<void> downloadUpdate() async {
if (_folderUrl == null) {
throw Exception("Folder URL is not set");
}
if (_changedFiles == null && _changedFiles!.isEmpty) {
throw Exception("Changed files are not set");
}
final stream = await _plugin.updateApp(
remoteUpdateFolder: _folderUrl!,
changedFiles: _changedFiles ?? [],
);
stream.listen(
(event) {
_updateProgress = event;
// if (_downloadProgress >= 1.0) {
// _isDownloading = false;
// _downloadProgress = 1.0;
// _downloadedSize = _downloadSize;
// _isDownloaded = true;
// notifyListeners();
// return;
// }
_isDownloading = true;
_isDownloaded = false;
_downloadProgress = event.receivedBytes / event.totalBytes;
_downloadedSize = _downloadSize * _downloadProgress;
notifyListeners();
},
onDone: () {
_isDownloading = false;
_downloadProgress = 1.0;
_downloadedSize = _downloadSize;
_isDownloaded = true;
notifyListeners();
},
);
}