updateNotifications method

void updateNotifications(
  1. List<NotificationData> notifications
)

Implementation

void updateNotifications(List<NotificationData> notifications) {
  setState(() {
    final currentIds = notifications.map((n) => n.id).toSet();
    final toRemove = _controllers.keys
        .where((id) => !currentIds.contains(id))
        .toList();

    for (final id in toRemove) {
      _controllers[id]?.dispose();
      _controllers.remove(id);
      _animations.remove(id);
    }

    _initializeAnimations();
  });
}