Skip to content

High performance self-hosted photo and video management solution.

Fix crash at first start when 'userInfoBox' does not contain 'serverEndpointKey' before API service is initialized (#1362)

Matthias Ruppa8cbda5f249e
diff --git a/mobile/lib/shared/services/api.service.dart b/mobile/lib/shared/services/api.service.dart
index 3251883e72..8f8a7c4770 100644
--- a/mobile/lib/shared/services/api.service.dart
+++ b/mobile/lib/shared/services/api.service.dart
@@ -20,8 +20,8 @@ class ApiService {
ApiService() {
if (Hive.isBoxOpen(userInfoBox)) {
- final endpoint = Hive.box(userInfoBox).get(serverEndpointKey) as String;
- if (endpoint.isNotEmpty) {
+ final endpoint = Hive.box(userInfoBox).get(serverEndpointKey) as String?;
+ if (endpoint != null && endpoint.isNotEmpty) {
setEndpoint(endpoint);
}
} else {