copyWith method
Message
copyWith({
- bool? isDeleted,
- bool? isDeletedForMe,
- bool? isEdited,
- bool? isForwarded,
- bool? isPinned,
- bool? isRemoved,
- bool clearReplyId = false,
- String? id,
- String? roomId,
- String? senderId,
- String? replyId,
- String? react,
- ChatValueTimestamp? createdAt,
- ChatValueTimestamp? editedAt,
- ChatValueTimestamp? updatedAt,
- MessageStatus? status,
- MessageExtra? extra,
Implementation
Message copyWith({
bool? isDeleted,
bool? isDeletedForMe,
bool? isEdited,
bool? isForwarded,
bool? isPinned,
bool? isRemoved,
bool clearReplyId = false,
String? id,
String? roomId,
String? senderId,
String? replyId,
String? react,
ChatValueTimestamp? createdAt,
ChatValueTimestamp? editedAt,
ChatValueTimestamp? updatedAt,
MessageStatus? status,
MessageExtra? extra,
}) {
final deletes = Map<String, bool>.from(this.deletes);
if (isDeletedForMe == true) deletes[me] = true;
final removes = Map<String, bool>.from(this.removes);
if (isRemoved == true) removes[me] = true;
final pins = Map<String, bool>.from(this.pins);
if (isPinned != null) {
if (isPinned) {
pins[me] = true;
} else {
pins.remove(me);
}
}
final reactions = Map<String, String>.from(this.reactions);
if (react != null) {
if (react.isNotEmpty) {
reactions[me] = react;
} else {
reactions.remove(me);
}
}
final statuses = Map<String, MessageStatus>.from(this.statuses);
if (status != null) statuses[me] = status;
return Message(
id: id ?? this.id,
roomId: roomId ?? this.roomId,
senderId: senderId ?? this.senderId,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
editedAt: editedAt ?? this.editedAt,
replyId: clearReplyId ? null : (replyId ?? this.replyId),
isDeleted: isDeleted ?? this.isDeleted,
isEdited: isEdited ?? this.isEdited,
isForwarded: isForwarded ?? this.isForwarded,
extra: extra ?? this.extra,
type: type,
statuses: statuses,
deletes: deletes,
removes: removes,
pins: pins,
reactions: reactions,
);
}