From d8c2bdf4047fdf430f2b9a56e424ea7643e181b3 Mon Sep 17 00:00:00 2001 From: cogwheel <172976095+cogwheel0@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:30:33 +0530 Subject: [PATCH] feat(api): Handle null user settings response gracefully Improve error handling for user settings API call Prevent potential null or unexpected response types Return an empty map for new users without settings --- lib/core/services/api_service.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/core/services/api_service.dart b/lib/core/services/api_service.dart index c29c5fa..d8b0ecf 100644 --- a/lib/core/services/api_service.dart +++ b/lib/core/services/api_service.dart @@ -1520,7 +1520,12 @@ class ApiService { Future> getUserSettings() async { _traceApi('Fetching user settings'); final response = await _dio.get('/api/v1/users/user/settings'); - return response.data as Map; + final data = response.data; + // Handle null response from server (happens for new users with no settings) + if (data is Map) { + return data; + } + return {}; } Future updateUserSettings(Map settings) async {