copyWith method

Message copyWith({
  1. String? id,
  2. String? text,
  3. String? type,
  4. List<Attachment>? attachments,
  5. List<User>? mentionedUsers,
  6. Map<String, int>? reactionCounts,
  7. Map<String, int>? reactionScores,
  8. List<Reaction>? latestReactions,
  9. List<Reaction>? ownReactions,
  10. String? parentId,
  11. Message? quotedMessage,
  12. String? quotedMessageId,
  13. int? replyCount,
  14. List<User>? threadParticipants,
  15. bool? showInChannel,
  16. bool? shadowed,
  17. bool? silent,
  18. String? command,
  19. DateTime? createdAt,
  20. DateTime? updatedAt,
  21. DateTime? deletedAt,
  22. User? user,
  23. bool? pinned,
  24. DateTime? pinnedAt,
  25. Object? pinExpires = _pinExpires,
  26. User? pinnedBy,
  27. Map<String, Object?>? extraData,
  28. MessageSendingStatus? status,
  29. Map<String, String>? i18n,
})

Creates a copy of Message with specified attributes overridden.

Implementation

Message copyWith({
  String? id,
  String? text,
  String? type,
  List<Attachment>? attachments,
  List<User>? mentionedUsers,
  Map<String, int>? reactionCounts,
  Map<String, int>? reactionScores,
  List<Reaction>? latestReactions,
  List<Reaction>? ownReactions,
  String? parentId,
  Message? quotedMessage,
  String? quotedMessageId,
  int? replyCount,
  List<User>? threadParticipants,
  bool? showInChannel,
  bool? shadowed,
  bool? silent,
  String? command,
  DateTime? createdAt,
  DateTime? updatedAt,
  DateTime? deletedAt,
  User? user,
  bool? pinned,
  DateTime? pinnedAt,
  Object? pinExpires = _pinExpires,
  User? pinnedBy,
  Map<String, Object?>? extraData,
  MessageSendingStatus? status,
  Map<String, String>? i18n,
}) {
  assert(() {
    if (pinExpires is! DateTime &&
        pinExpires != null &&
        pinExpires is! _PinExpires) {
      throw ArgumentError('`pinExpires` can only be set as DateTime or null');
    }
    return true;
  }(), 'Validate type for pinExpires');
  return Message(
    id: id ?? this.id,
    text: text ?? this.text,
    type: type ?? this.type,
    attachments: attachments ?? this.attachments,
    mentionedUsers: mentionedUsers ?? this.mentionedUsers,
    reactionCounts: reactionCounts ?? this.reactionCounts,
    reactionScores: reactionScores ?? this.reactionScores,
    latestReactions: latestReactions ?? this.latestReactions,
    ownReactions: ownReactions ?? this.ownReactions,
    parentId: parentId ?? this.parentId,
    quotedMessage: quotedMessage ?? this.quotedMessage,
    quotedMessageId: quotedMessageId ?? this.quotedMessageId,
    replyCount: replyCount ?? this.replyCount,
    threadParticipants: threadParticipants ?? this.threadParticipants,
    showInChannel: showInChannel ?? this.showInChannel,
    command: command ?? this.command,
    createdAt: createdAt ?? this.createdAt,
    silent: silent ?? this.silent,
    extraData: extraData ?? this.extraData,
    user: user ?? this.user,
    shadowed: shadowed ?? this.shadowed,
    updatedAt: updatedAt ?? this.updatedAt,
    deletedAt: deletedAt ?? this.deletedAt,
    status: status ?? this.status,
    pinned: pinned ?? this.pinned,
    pinnedAt: pinnedAt ?? this.pinnedAt,
    pinnedBy: pinnedBy ?? this.pinnedBy,
    pinExpires:
        pinExpires == _pinExpires ? this.pinExpires : pinExpires as DateTime?,
    i18n: i18n ?? this.i18n,
  );
}