From 14ce4c82fb4277bbf41e1d1f7546a1db848dd9b4 Mon Sep 17 00:00:00 2001 From: Kima Date: Wed, 27 Sep 2023 21:56:19 +0200 Subject: [PATCH] fixed test account crash --- filcnaplo/lib/models/user.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/filcnaplo/lib/models/user.dart b/filcnaplo/lib/models/user.dart index 9de5718..784c450 100644 --- a/filcnaplo/lib/models/user.dart +++ b/filcnaplo/lib/models/user.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'package:filcnaplo_kreta_api/client/api.dart'; +import 'package:filcnaplo_kreta_api/models/school.dart'; import 'package:filcnaplo_kreta_api/models/student.dart'; import 'package:uuid/uuid.dart'; @@ -43,7 +44,16 @@ class User { username: map["username"], password: map["password"], name: map["name"].trim(), - student: Student.fromJson(jsonDecode(map["student"])), + student: map["student"] != 'null' + ? Student.fromJson(jsonDecode(map["student"])) + : Student( + id: const Uuid().v4(), + name: 'Ismeretlen Diák', + school: School(instituteCode: '', name: '', city: ''), + birth: DateTime.now(), + yearId: '1', + parents: [], + ), role: Role.values[map["role"] ?? 0], nickname: map["nickname"] ?? "", picture: map["picture"] ?? "",