Message class
Represents a message in a chat
Constructors
-
Message({required String id, required String senderId, required String text, required DateTime timestamp, MessageStatus status = MessageStatus.sent, bool isOptimistic = false, String? replyToMessageId, String? replyToText, String? replyToSenderId, String? threadId, List<
MessageReaction> reactions = const [], List<MessageMedia> media = const [], Map<String, DateTime> readBy = const {}, Map<String, DateTime> deliveredTo = const {}, bool deleted = false, DateTime? deletedAt}) -
const
-
Message.fromFirestore(DocumentSnapshot<
Object?> doc) -
Creates a Message instance from Firebase document data
factory
-
Message.fromMap(Map<
String, dynamic> map, String id) -
Creates a Message instance from a Map
factory
Properties
-
audioFiles
→ List<
MessageMedia> -
Gets all audio files from media attachments
no setter
- deleted → bool
-
final
- deletedAt → DateTime?
-
final
-
deliveredTo
→ Map<
String, DateTime> -
final
-
files
→ List<
MessageMedia> -
Gets all files from media attachments
no setter
- hasAudio → bool
-
Checks if this message has audio files
no setter
- hasFiles → bool
-
Checks if this message has files
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasImages → bool
-
Checks if this message has images
no setter
- hasMedia → bool
-
Checks if this message has media attachments
no setter
- hasReactions → bool
-
Checks if this message has any reactions
no setter
- hasVideos → bool
-
Checks if this message has videos
no setter
- id → String
-
final
-
images
→ List<
MessageMedia> -
Gets all images from media attachments
no setter
- isOptimistic → bool
-
final
- isReply → bool
-
Checks if this message is a reply to another message
no setter
- isSystemMessage → bool
-
Checks if this is a system message
no setter
- isThreadMessage → bool
-
Checks if this message is part of a thread
no setter
-
media
→ List<
MessageMedia> -
final
-
reactions
→ List<
MessageReaction> -
final
-
readBy
→ Map<
String, DateTime> -
final
- replyToMessageId → String?
-
final
- replyToSenderId → String?
-
final
- replyToText → String?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- senderId → String
-
final
- status → MessageStatus
-
final
- text → String
-
final
- threadId → String?
-
final
- timestamp → DateTime
-
final
- totalReactionCount → int
-
Gets the total count of reactions
no setter
-
videos
→ List<
MessageMedia> -
Gets all videos from media attachments
no setter
Methods
-
copyWith(
{String? id, String? senderId, String? text, DateTime? timestamp, MessageStatus? status, bool? isOptimistic, String? replyToMessageId, String? replyToText, String? replyToSenderId, String? threadId, List< MessageReaction> ? reactions, List<MessageMedia> ? media, Map<String, DateTime> ? readBy, Map<String, DateTime> ? deliveredTo, bool? deleted, DateTime? deletedAt}) → Message - Creates a copy of Message with updated fields
-
getDeliveredCount(
) → int - Get count of participants who have received this message
-
getDeliveryTimeFor(
String userId) → DateTime? - Get the time when message was delivered to a specific user
-
getReadCount(
) → int - Get count of participants who have read this message
-
getReadTimeFor(
String userId) → DateTime? - Get the time when message was read by a specific user
-
getUserReactions(
String userId) → List< String> - Gets all emojis the user has reacted with
-
hasUserReacted(
String userId, String emoji) → bool - Checks if a user has reacted with a specific emoji
-
isDeliveredTo(
String userId) → bool - Check if message has been delivered to a specific user
-
isDeliveredToAll(
List< String> participantIds) → bool - Check if message has been delivered to all participants (except sender)
-
isReadBy(
String userId) → bool - Check if message has been read by a specific user
-
isReadByAll(
List< String> participantIds) → bool - Check if message has been read by all participants (except sender)
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> - Converts Message instance to Map for Firestore storage
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override