ChannelModel constructor
ChannelModel()
Constructor used for json serialization
Implementation
ChannelModel({
String? id,
String? type,
String? cid,
ChannelConfig? config,
this.createdBy,
this.frozen = false,
this.lastMessageAt,
DateTime? createdAt,
DateTime? updatedAt,
this.deletedAt,
this.memberCount = 0,
this.extraData = const {},
this.team,
this.cooldown = 0,
}) : assert(
(cid != null && cid.contains(':')) || (id != null && type != null),
'provide either a cid or an id and type',
),
id = id ?? cid!.split(':')[1],
type = type ?? cid!.split(':')[0],
cid = cid ?? '$type:$id',
config = config ?? ChannelConfig(),
createdAt = createdAt ?? DateTime.now(),
updatedAt = updatedAt ?? DateTime.now();