Initial commit

This commit is contained in:
admin1
2026-07-14 11:11:36 +08:00
commit 656499cf94
604 changed files with 119518 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
class AppUpdateAsset {
final String name;
final String downloadUrl;
final int size;
final String? sha256;
final String? version;
const AppUpdateAsset({
required this.name,
required this.downloadUrl,
required this.size,
this.sha256,
this.version,
});
factory AppUpdateAsset.fromJson(Map<String, dynamic> json) {
return AppUpdateAsset(
name: json['name']?.toString() ?? '',
downloadUrl:
json['browser_download_url']?.toString() ??
json['browserDownloadUrl']?.toString() ??
json['url']?.toString() ??
'',
size: json['size'] is int ? json['size'] as int : 0,
sha256: (json['sha256']?.toString().trim().isEmpty ?? true)
? null
: json['sha256'].toString().trim().toLowerCase(),
version: (json['version']?.toString().trim().isEmpty ?? true)
? null
: json['version'].toString().trim(),
);
}
}
class AppUpdateInfo {
final String version;
final String releaseNotes;
final Uri htmlUrl;
final List<AppUpdateAsset> assets;
final Map<String, AppUpdateAsset> platformAssets;
final AppUpdateAsset? selectedAsset;
final bool noAssetForPlatform;
const AppUpdateInfo({
required this.version,
required this.releaseNotes,
required this.htmlUrl,
required this.assets,
this.platformAssets = const {},
this.selectedAsset,
this.noAssetForPlatform = false,
});
AppUpdateInfo copyWith({
String? version,
String? releaseNotes,
Uri? htmlUrl,
List<AppUpdateAsset>? assets,
Map<String, AppUpdateAsset>? platformAssets,
AppUpdateAsset? selectedAsset,
bool? noAssetForPlatform,
}) {
return AppUpdateInfo(
version: version ?? this.version,
releaseNotes: releaseNotes ?? this.releaseNotes,
htmlUrl: htmlUrl ?? this.htmlUrl,
assets: assets ?? this.assets,
platformAssets: platformAssets ?? this.platformAssets,
selectedAsset: selectedAsset ?? this.selectedAsset,
noAssetForPlatform: noAssetForPlatform ?? this.noAssetForPlatform,
);
}
}
class UpdateCheckResult {
final bool hasUpdate;
final AppUpdateInfo? info;
const UpdateCheckResult({required this.hasUpdate, this.info});
}