MessageGroup class

A group of consecutive messages from the same sender.

This class implements message grouping logic to create a natural conversation flow by combining messages from the same sender that are sent within a short time period. This follows the Aggregate pattern from Domain-Driven Design.

Messages are grouped when they:

  • Come from the same sender
  • Are sent within the same minute
  • Maintain chronological order

Example usage:

final group = MessageGroup(
  name: "John",
  isSender: false,
  timestamp: "2023-01-01T12:00:00Z",
  messages: [message1, message2],
);
group.sortMessages(); // Ensures proper ordering

Constructors

MessageGroup({required List<Message> messages, required String name, required bool isSender, required String timestamp})

Properties

hashCode int
The hash code for this object.
no setterinherited
isSender bool
Whether this group contains messages from the sender.
final
messages List<Message>
List of messages in this group.
final
name String
Display name of the sender for this group.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timestamp String
Timestamp of the first message in this group.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sortMessages() → void
Sorts messages in this group by timestamp and failure state.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited