copyWith method
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,
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,
);
}