arch-atlas

NotificationsState

controllers/notifications_controller.dart · const class

domain

Overview

Immutable state holding isLoading, the merged notifications list, and an optional error. Exposes a derived unreadCount used by the bell badge.

User Flow

  1. const default is NotificationsState(isLoading: true, notifications: const []).
  2. copyWith allows partial updates; error is intentionally pass-through (passing null clears).
  3. 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.