import 'package:flutter/material.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; class NotificationProvider with ChangeNotifier { List> _notifications = []; int _unreadCount = 0; List> get notifications => _notifications; int get unreadCount => _unreadCount; // Add new notification void addNotification(Map notification) { _notifications.insert(0, notification); _unreadCount++; notifyListeners(); } // Mark as read void markAsRead(int index) { if (index < _notifications.length) { _notifications[index]['isRead'] = true; _unreadCount--; notifyListeners(); } } // Mark all as read void markAllAsRead() { for (var notification in _notifications) { notification['isRead'] = true; } _unreadCount = 0; notifyListeners(); } // Clear all notifications void clearAll() { _notifications.clear(); _unreadCount = 0; notifyListeners(); } }