copyWith method
Room
copyWith({
- Iterable<
String> ? blocks, - ChatValueTimestamp? createdAt,
- String? createdBy,
- RoomExtra? extra,
- String? id,
- bool? isAddMember,
- bool? isArchived,
- bool? isBlocked,
- bool? isBot,
- bool? isDeleted,
- bool? isGroup,
- bool? isLeaved,
- bool? isLocal,
- bool? isMuted,
- bool? isPinned,
- bool? isRemoved,
- bool? isRestricted,
- bool? isVerified,
- bool clearLastMessage = false,
- String? lastMessage,
- bool? lastMessageDeleted,
- String? lastMessageId,
- String? lastMessageSenderId,
- Map<
String, MessageStatus> ? lastMessageStatuses, - Iterable<
String> ? participants, - Iterable<
String> ? restricts, - Map<
String, int> ? unseenCounts, - ChatValueTimestamp? updatedAt,
Implementation
Room copyWith({
Iterable<String>? blocks,
ChatValueTimestamp? createdAt,
String? createdBy,
RoomExtra? extra,
String? id,
bool? isAddMember,
bool? isArchived,
bool? isBlocked,
bool? isBot,
bool? isDeleted,
bool? isGroup,
bool? isLeaved,
bool? isLocal,
bool? isMuted,
bool? isPinned,
bool? isRemoved,
bool? isRestricted,
bool? isVerified,
bool clearLastMessage = false,
String? lastMessage,
bool? lastMessageDeleted,
String? lastMessageId,
String? lastMessageSenderId,
Map<String, MessageStatus>? lastMessageStatuses,
Iterable<String>? participants,
Iterable<String>? restricts,
Map<String, int>? unseenCounts,
ChatValueTimestamp? updatedAt,
}) {
final mArchives = {...archives};
if (isArchived != null) {
isArchived ? mArchives.add(me) : mArchives.remove(me);
}
final mBlocks = {...this.blocks};
if (isBlocked != null && blocks != null && blocks.isNotEmpty) {
isBlocked ? mBlocks.addAll(blocks) : mBlocks.removeAll(blocks);
}
final mLeaves = {...leaves};
if (isLeaved != null) {
isLeaved ? mLeaves.add(me) : mLeaves.remove(me);
}
final mMutes = {...mutes};
if (isMuted != null) {
isMuted ? mMutes.add(me) : mMutes.remove(me);
}
final mPins = {...pins};
if (isPinned != null) {
isPinned ? mPins.add(me) : mPins.remove(me);
}
final mParticipants = {...this.participants};
if (isAddMember != null &&
participants != null &&
participants.isNotEmpty) {
isAddMember
? mParticipants.addAll(participants)
: mParticipants.removeAll(participants);
}
final mRemoves = {...removes};
if (isRemoved != null &&
lastMessageId != null &&
lastMessageId.isNotEmpty) {
isRemoved ? mRemoves[me] = lastMessageId : mRemoves.remove(me);
}
final mRestricts = {...this.restricts};
if (isRestricted != null && restricts != null && restricts.isNotEmpty) {
isRestricted
? mRestricts.addAll(restricts)
: mRestricts.removeAll(restricts);
}
return Room(
archives: mArchives,
blocks: mBlocks,
createdAt: createdAt ?? this.createdAt,
createdBy: createdBy ?? this.createdBy,
extra: extra ?? this.extra,
id: id ?? this.id,
isBot: isBot ?? this.isBot,
isDeleted: isDeleted ?? this.isDeleted,
isGroup: isGroup ?? this.isGroup,
isLocal: isLocal ?? this.isLocal,
isVerified: isVerified ?? this.isVerified,
lastMessage: clearLastMessage ? null : (lastMessage ?? this.lastMessage),
lastMessageDeleted: lastMessageDeleted ?? this.lastMessageDeleted,
lastMessageId: lastMessageId ?? this.lastMessageId,
lastMessageSenderId: lastMessageSenderId ?? this.lastMessageSenderId,
lastMessageStatuses: lastMessageStatuses ?? this.lastMessageStatuses,
leaves: mLeaves,
mutes: mMutes,
participants: mParticipants,
pins: mPins,
removes: mRemoves,
restricts: mRestricts,
unseenCounts: unseenCounts ?? _unseenCounts,
updatedAt: updatedAt ?? this.updatedAt,
);
}