From 5320fa1a2b7b98569602b34ede8eb947e19509ab Mon Sep 17 00:00:00 2001 From: Janez T Date: Sat, 4 Apr 2026 15:58:21 +0200 Subject: [PATCH] fix: Guard null history decode #123 --- lib/services/path_history_service.dart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/services/path_history_service.dart b/lib/services/path_history_service.dart index e2bca41..d395c33 100644 --- a/lib/services/path_history_service.dart +++ b/lib/services/path_history_service.dart @@ -69,12 +69,17 @@ class PathHistoryService { } try { - final decoded = jsonDecode(raw); - if (decoded is Map) { - for (final entry in decoded.entries) { - final value = entry.value; - if (value is Map) { - _cache[entry.key] = ContactPathHistory.fromJson(entry.key, value); + if (raw != null && raw.isNotEmpty) { + final decoded = jsonDecode(raw); + if (decoded is Map) { + for (final entry in decoded.entries) { + final value = entry.value; + if (value is Map) { + _cache[entry.key] = ContactPathHistory.fromJson( + entry.key, + value, + ); + } } } }