import 'dart:async'; import 'dart:convert'; import 'package:shared_preferences/src/shared_preferences_legacy.dart'; import '../globals.dart' as globals; import 'fireNotification.dart'; const String fireNotificationKey = 'fireNotifications'; Future> loadFireNotifications() async { return globals.prefs.then((SharedPreferences prefs) { final List? FireNotifications = prefs.getStringList(fireNotificationKey); final List persistedList = []; for (final String notificationString in (FireNotifications ?? [])) { final Map notificationMap = json.decode(notificationString) as Map; persistedList.add(FireNotification.fromJson(notificationMap)); } return persistedList; }); } void persistFireNotifications(List notif) { // print('Persisting $notif'); globals.prefs.then((SharedPreferences prefs) { final List notifAsString = []; notif .whereType() .forEach((FireNotification notification) { notifAsString.add(json.encode(notification.toJson())); }); prefs.setStringList(fireNotificationKey, notifAsString); }); }