fix: reformat code / code improvements

This commit is contained in:
2026-07-30 01:46:01 +02:00
parent a732e2d07f
commit 498ad68e1c
15 changed files with 85 additions and 169 deletions
-97
View File
@@ -83,101 +83,4 @@ class AppUpdateUtil {
return UpdateInfo.fromJson(data);
}
// /// Downloads the APK
// Future<File> downloadApk(
// UpdateInfo update, {
//
// Function(double progress)? onProgress,
// }) async {
// final url = update.download.startsWith("http")
// ? update.download
// : "$serverUrl${update.download}";
//
// final request = http.Request("GET", Uri.parse(url));
//
// final response = await request.send();
//
// if (response.statusCode != 200) {
// throw Exception("APK download failed");
// }
//
// final total = response.contentLength ?? 0;
//
// int received = 0;
//
// final directory = await getTemporaryDirectory();
//
// final file = File("${directory.path}/update.apk");
//
// final sink = file.openWrite();
//
// await for (final chunk in response.stream) {
// sink.add(chunk);
//
// received += chunk.length;
//
// if (total > 0 && onProgress != null) {
// onProgress(received / total);
// }
// }
//
// await sink.close();
//
// return file;
// }
//
// /// Verifies APK checksum
// Future<bool> verifySha256(File file, String expectedHash) async {
// final bytes = await file.readAsBytes();
//
// final digest = sha256.convert(bytes);
//
// return digest.toString().toLowerCase() == expectedHash.toLowerCase();
// }
//
// /// Opens Android APK installer
// Future<void> installApk(File file) async {
// final result =
// await OpenFilex.open(
// file.path,
// );
//
// if(result.type == ResultType.done) {
// debugPrint("APK installer opened successfully");
// }
//
//
// if (result.type != ResultType.done) {
// throw Exception(
// "Could not open APK installer",
// );
// }
// }
//
// /// Full update flow
// ///
// /// Returns:
// /// - null if no update exists
// /// - UpdateInfo if update is available
// ///
// Future<UpdateInfo?> update({Function(double progress)? onProgress}) async {
// final info = await checkForUpdate();
//
// if (info == null) {
// return null;
// }
//
// final apk = await downloadApk(info, onProgress: onProgress);
//
// final valid = await verifySha256(apk, info.sha256);
//
// if (!valid) {
// throw Exception("APK checksum mismatch");
// }
//
// await installApk(apk);
//
// return info;
// }
}
+9
View File
@@ -0,0 +1,9 @@
bool listEquals<T>(List<T>? a, List<T>? b) {
if (identical(a, b)) return true;
if (a == null || b == null) return a == b;
if (a.length != b.length) return false;
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) return false;
}
return true;
}