feat: check for correct version

This commit is contained in:
alzalia1 2025-08-13 14:16:34 +02:00
parent b751d93be6
commit 8e379241ee
6 changed files with 169 additions and 92 deletions

View file

@ -66,4 +66,23 @@ class AuthClient {
client.close();
}
}
Future<Result<int>> getRemoteApiVersion() async {
final client = http.Client();
try {
final response = await client.get(
Uri.parse("https://$apiBasePath/version"),
);
if (response.statusCode == 200) {
final json = jsonDecode(response.body) as int;
return Result.ok(json);
} else {
throw "Something wrong happened";
}
} catch (e) {
return Result.error(Exception(e));
} finally {
client.close();
}
}
}