NotificationItem + Type
models/notification_item.dart
Overview
Single notification entity: id, title, body, NotificationType enum (order / post / promotion / system / message), template string, createdAt, isRead, payload bag, and the authToken under which it was fetched (so mark-as-read can hit the right token).
User Flow
- NotificationItem.fromJson reads title from data.title or falls back to template string.
- _typeFromTemplate maps backend template strings to the local NotificationType enum.
- NotificationTypeUI extension provides per-type icon, color, lightColor, darkColor and French label.
- NotificationsResponse.fromJson wraps the paginated list with count/limit/offset.
Cases & Edge Cases
- Unknown template strings fall back to NotificationType.system (grey, info icon) — defensive against new backend templates.
- authToken is propagated through copyWith — without it, markAsRead can't tell which role's endpoint to call.
- createdAt defaults to DateTime.now() when missing — only affects sort order, never delivered server-side.
Code References
- lib/src/features/shared/notifications/models/notification_item.dart:4 // NotificationType enum
- lib/src/features/shared/notifications/models/notification_item.dart:90 // _typeFromTemplate
- lib/src/features/shared/notifications/models/notification_item.dart:111 // NotificationItem
- lib/src/features/shared/notifications/models/notification_item.dart:180 // NotificationsResponse
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
The French labels are hard-coded in the extension — should move to ARB if multi-language coverage is added.