Skip to content

Chat Models

Source: pharmanet/lib/core/models/chat_model.dart

ChatRoom — @freezed

Field Type Description
id String UUID
createdAt DateTime? Room creation
updatedAt DateTime? Last activity
lastMessage String? Latest message preview
lastMessageType String text, image, file
lastMessageAttachmentUrl String? Latest attachment
lastMessageAt DateTime? Last activity time
productId String? Context: product inquiry
unreadCount int Unread messages count
participantIds List<String>? (ignored in JSON) Joined at runtime
otherParticipantName String? (ignored in JSON) Computed display name
otherParticipantPhoto String? (ignored in JSON) Computed photo
productName String? (ignored in JSON) Context product
productPhoto String? (ignored in JSON) Context product image
isOnline bool (ignored in JSON) Real-time online status

ChatMessage — @freezed

Field Type Description
id String UUID
chatId String FK to chats
senderId String FK to profiles
content String Message text
createdAt DateTime? Sent timestamp
isRead bool Read status
type String text, image, file
attachmentUrl String? Image/file URL