ChannelModel constructor
ChannelModel({
- String? id,
- String? type,
- String? cid,
- List<
String> ? ownCapabilities, - ChannelConfig? config,
- User? createdBy,
- bool frozen = false,
- DateTime? lastMessageAt,
- DateTime? createdAt,
- DateTime? updatedAt,
- DateTime? deletedAt,
- int memberCount = 0,
- Map<
String, Object?> extraData = const {}, - String? team,
- int cooldown = 0,
- bool? disabled,
- DateTime? truncatedAt,
Constructor used for json serialization
Implementation
ChannelModel({
String? id,
String? type,
String? cid,
this.ownCapabilities,
ChannelConfig? config,
this.createdBy,
this.frozen = false,
this.lastMessageAt,
DateTime? createdAt,
DateTime? updatedAt,
this.deletedAt,
this.memberCount = 0,
Map<String, Object?> extraData = const {},
this.team,
this.cooldown = 0,
bool? disabled,
bool? hidden,
DateTime? truncatedAt,
}) : 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(),
// TODO: Make them top-level fields in v5
// For backwards compatibility, set 'disabled', 'hidden'
// and 'truncated_at' in [extraData].
extraData = {
...extraData,
if (disabled != null) 'disabled': disabled,
if (hidden != null) 'hidden': hidden,
if (truncatedAt != null)
'truncated_at': truncatedAt.toIso8601String(),
};