瀏覽代碼

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

Matthias Rupp 2 年之前
父節點
當前提交
a8cbda5f24
共有 1 個文件被更改,包括 2 次插入2 次删除
  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 {