upgradeFromDownload method
Implementation
Future<bool> upgradeFromDownload() async {
bool shouldRestartDownload = false;
_downloadIsFinish = false;
if (downloadUseCache != true) {
shouldRestartDownload = true;
} else {
_downloadId = await RUpgrade.getLastUpgradedId();
if (_downloadId != null) {
final status = await RUpgrade.getDownloadStatus(_downloadId!);
if (status == DownloadStatus.STATUS_SUCCESSFUL) {
_downloadIsFinish = true;
await RUpgrade.upgradeWithId(_downloadId!);
} else if (status == DownloadStatus.STATUS_FAILED) {
shouldRestartDownload = true;
} else {
await RUpgrade.upgradeWithId(_downloadId!);
}
} else {
shouldRestartDownload = true;
}
}
if (shouldRestartDownload) {
assert(downloadUrl != null, 'Please set android downloadUrl');
_downloadId = await RUpgrade.upgrade(
downloadUrl!,
header: downloadHeader,
fileName: downloadFileName,
notificationVisibility:
notificationVisibility ?? NotificationVisibility.VISIBILITY_VISIBLE,
notificationStyle: notificationStyle ?? NotificationStyle.planTime,
isAutoRequestInstall: downloadFinishAutoInstall ?? true,
upgradeFlavor: upgradeFlavor,
);
}
return false;
}