Browse Source

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

Matthias Rupp 2 years ago
parent
commit
a8cbda5f24
1 changed files with 2 additions and 2 deletions
  1. 2 2
      mobile/lib/shared/services/api.service.dart

+ 2 - 2
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 {