Message class abstract

Abstract base class representing a chat message.

This class follows the Template Method pattern by defining the common structure and behavior for all message types while allowing specific implementations for different message directions (sender/receiver).

Key features:

  • Unique identification and timestamp tracking
  • Element-based content structure for rich messages
  • Loading and failure state management
  • Immutable message copying with state updates

See also:

Implementers

Constructors

Message({required String name, required String id, required String timestamp, required List<MessageElement> elements, bool isLoading = false, bool isFailed = false, double? width})

Properties

elements List<MessageElement>
List of content elements that make up the message.
final
hashCode int
The hash code for this object.
no setterinherited
id String
Unique identifier for this message.
final
isFailed bool
Whether the message failed to send or process.
final
isLoading bool
Whether the message is currently in a loading state.
final
isSender bool
Whether this message is from the sender.
no setter
name String
Display name of the message author.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timestamp String
ISO 8601 timestamp when the message was created.
final
width double?
Optional width constraint for the message bubble.
final

Methods

copyWith({String? timestamp, bool? isLoading, List<MessageElement>? elements, bool? isFailed, double? width}) Message
Creates a copy of this message with updated properties.
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