MessageGroupHelper class

Utility class that computes GroupInfo for a flat list of messages.

Two consecutive messages belong to the same group when:

  • They have the same senderId, AND
  • Either no timestamps are provided, OR the time gap between them is less than threshold.

Example

final ids = ['alice', 'alice', 'bob', 'alice'];
final infos = MessageGroupHelper.compute(senderIds: ids);
// infos[0]: isGroupStart=true,  isGroupEnd=false, showTail=false
// infos[1]: isGroupStart=false, isGroupEnd=true,  showTail=true
// infos[2]: isGroupStart=true,  isGroupEnd=true,  showTail=true, isAlone=true
// infos[3]: isGroupStart=true,  isGroupEnd=true,  showTail=true, isAlone=true

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

compute({required List<String> senderIds, List<DateTime>? timestamps, Duration threshold = const Duration(minutes: 1)}) List<GroupInfo>
Computes grouping information for each message in the list.