diff --git a/lib/business/notifications.dart b/lib/business/notifications.dart index 863b9d72..cd6ea1f6 100644 --- a/lib/business/notifications.dart +++ b/lib/business/notifications.dart @@ -272,18 +272,20 @@ class Notifications { notifications.clear(); if (_ls.prefs.containsKey(notificationPrefs)) { - var jsonMap = jsonDecode(_ls.prefs.getString(notificationPrefs)!); - - for (var notification in jsonMap["notifications"]) { - EnvoyNotification notificationToRestore = - EnvoyNotification.fromJson(notification); - - // Migration: tx notifications previously didn't have account data - notificationToRestore = addMissingAccountId(notificationToRestore); - - // Only add tx notifications that link to an account - if (!_shouldBeRemoved(notificationToRestore)) { - add(notificationToRestore); + String? jsonString = _ls.prefs.getString(notificationPrefs); + if (jsonString != null) { + var jsonMap = jsonDecode(jsonString); + for (var notification in jsonMap["notifications"]) { + EnvoyNotification notificationToRestore = + EnvoyNotification.fromJson(notification); + + // Migration: tx notifications previously didn't have account data + notificationToRestore = addMissingAccountId(notificationToRestore); + + // Only add tx notifications that link to an account + if (!_shouldBeRemoved(notificationToRestore)) { + add(notificationToRestore); + } } } }