claude refactorings, flutter best practices, platform dependent changes, general cleanup

This commit is contained in:
2026-05-06 11:58:50 +02:00
parent 4b1d4379a0
commit 4e1272aba9
281 changed files with 1948 additions and 1041 deletions
@@ -2,9 +2,9 @@ import 'dart:async';
import 'dart:convert';
import '../../../../model/account_data.dart';
import '../../webuntisApi.dart';
import 'authenticateParams.dart';
import 'authenticateResponse.dart';
import '../../webuntis_api.dart';
import 'authenticate_params.dart';
import 'authenticate_response.dart';
class Authenticate extends WebuntisApi {
AuthenticateParams param;
@@ -15,18 +15,19 @@ class Authenticate extends WebuntisApi {
Future<AuthenticateResponse> run() async {
awaitingResponse = true;
try {
var rawAnswer = await query(this);
AuthenticateResponse response = finalize(AuthenticateResponse.fromJson(jsonDecode(rawAnswer)['result']));
final rawAnswer = await query(this);
final decoded = jsonDecode(rawAnswer) as Map<String, dynamic>;
final response = finalize(AuthenticateResponse.fromJson(decoded['result'] as Map<String, dynamic>));
_lastResponse = response;
if(!awaitedResponse.isCompleted) awaitedResponse.complete();
if (!awaitedResponse.isCompleted) awaitedResponse.complete();
return response;
} catch (e) {
// Surface the error to anyone waiting on the current completer, then
// install a fresh one so a future attempt can succeed. Without this,
// any later call to getSession() would hang forever on a completer
// that is already settled with no listeners (or never settles at all).
if(!awaitedResponse.isCompleted) awaitedResponse.completeError(e);
awaitedResponse = Completer();
if (!awaitedResponse.isCompleted) awaitedResponse.completeError(e);
awaitedResponse = Completer<void>();
rethrow;
} finally {
awaitingResponse = false;
@@ -34,7 +35,7 @@ class Authenticate extends WebuntisApi {
}
static bool awaitingResponse = false;
static Completer awaitedResponse = Completer();
static Completer<void> awaitedResponse = Completer<void>();
static AuthenticateResponse? _lastResponse;
static Future<void> createSession() async {