feat: add alot
This commit is contained in:
@@ -24,12 +24,12 @@ class UpdateInfo {
|
||||
|
||||
factory UpdateInfo.fromJson(Map<String, dynamic> json) {
|
||||
return UpdateInfo(
|
||||
update: json["update"] ?? false,
|
||||
version: json["version"] ?? "",
|
||||
notes: json["notes"] ?? "",
|
||||
mandatory: json["mandatory"] ?? false,
|
||||
sha256: json["sha256"] ?? "",
|
||||
download: json["download"] ?? "",
|
||||
update: json['update'] ?? false,
|
||||
version: json['version'] ?? '',
|
||||
notes: json['notes'] ?? '',
|
||||
mandatory: json['mandatory'] ?? false,
|
||||
sha256: json['sha256'] ?? '',
|
||||
download: json['download'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,26 +56,26 @@ class AppUpdateUtil {
|
||||
|
||||
Future<String> currentVersion() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
debugPrint("Current app version: ${info.version}");
|
||||
debugPrint('Current app version: ${info.version}');
|
||||
return info.version;
|
||||
}
|
||||
|
||||
Future<UpdateInfo?> checkForUpdate() async {
|
||||
final version = await currentVersion();
|
||||
|
||||
final url = Uri.parse("$serverUrl/api/update?version=$version");
|
||||
final url = Uri.parse('$serverUrl/api/update?version=$version');
|
||||
|
||||
final response = await http.get(url);
|
||||
|
||||
debugPrint("Response from update server: ${response.body}");
|
||||
debugPrint('Response from update server: ${response.body}');
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception("Update server unavailable");
|
||||
throw Exception('Update server unavailable');
|
||||
}
|
||||
|
||||
final data = jsonDecode(response.body);
|
||||
|
||||
if (data["update"] != true) {
|
||||
if (data['update'] != true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user