copyWith method

ChatMessage copyWith({
  1. String? id,
  2. String? content,
  3. bool? isUser,
  4. DateTime? timestamp,
})

Creates a copy of this message with some fields replaced.

Only the specified fields will be changed; all others remain the same.

Example:

final updatedMessage = message.copyWith(content: 'Updated content');

Implementation

ChatMessage copyWith({
  String? id,
  String? content,
  bool? isUser,
  DateTime? timestamp,
}) =>
    ChatMessage(
      id: id ?? this.id,
      content: content ?? this.content,
      isUser: isUser ?? this.isUser,
      timestamp: timestamp ?? this.timestamp,
    );