2026-05-27 16:05:21 +08:00
|
|
|
import 'version_check_service.dart';
|
|
|
|
|
|
|
|
|
|
/// 更新状态基类
|
|
|
|
|
abstract class UpdateState {
|
|
|
|
|
const UpdateState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 初始状态
|
|
|
|
|
class UpdateInitial extends UpdateState {
|
|
|
|
|
const UpdateInitial();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 检查中
|
|
|
|
|
class UpdateChecking extends UpdateState {
|
|
|
|
|
const UpdateChecking();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 发现新版本
|
|
|
|
|
class UpdateAvailable extends UpdateState {
|
|
|
|
|
final AppVersionInfo versionInfo;
|
|
|
|
|
|
|
|
|
|
const UpdateAvailable(this.versionInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 下载中
|
|
|
|
|
class UpdateDownloading extends UpdateState {
|
|
|
|
|
final double progress;
|
|
|
|
|
final bool isPatch; // true=差量补丁, false=完整APK
|
|
|
|
|
|
|
|
|
|
const UpdateDownloading(this.progress, {required this.isPatch});
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
/// 清理版本号中
|
|
|
|
|
class UpdateClearingVersion extends UpdateState {
|
|
|
|
|
const UpdateClearingVersion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 准备安装
|
|
|
|
|
class UpdateReadyToInstall extends UpdateState {
|
|
|
|
|
final String apkPath;
|
|
|
|
|
|
|
|
|
|
const UpdateReadyToInstall(this.apkPath);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-27 16:05:21 +08:00
|
|
|
/// 安装中
|
|
|
|
|
class UpdateInstalling extends UpdateState {
|
|
|
|
|
final bool isPatch;
|
|
|
|
|
|
|
|
|
|
const UpdateInstalling({required this.isPatch});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 更新成功
|
|
|
|
|
class UpdateSuccess extends UpdateState {
|
|
|
|
|
const UpdateSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 已是最新版本
|
|
|
|
|
class UpdateUpToDate extends UpdateState {
|
|
|
|
|
const UpdateUpToDate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 更新失败
|
|
|
|
|
class UpdateFailure extends UpdateState {
|
|
|
|
|
final String error;
|
|
|
|
|
|
|
|
|
|
const UpdateFailure(this.error);
|
|
|
|
|
}
|