NotificationsState
controllers/notifications_controller.dart · const class
Overview
Immutable state holding isLoading, the merged notifications list, and an optional error. Exposes a derived unreadCount used by the bell badge.
User Flow
- const default is NotificationsState(isLoading: true, notifications: const []).
- copyWith allows partial updates; error is intentionally pass-through (passing null clears).
- unreadCount = notifications.where(!isRead).length — recomputed per watcher.
Cases & Edge Cases
- unreadCount is O(n) — fine for ~50 items; if pagination grows, cache it on update.
- An empty list with a non-null error is a valid 'we tried, failed' state — UI should show retry, not skeleton.
Code References
- lib/src/features/shared/notifications/controllers/notifications_controller.dart:12 // NotificationsState
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
Stays in the same file as the controller — split if state grows independent concerns.