ChannelModel constructor

ChannelModel(
  1. {String? id,
  2. String? type,
  3. String? cid,
  4. ChannelConfig? config,
  5. User? createdBy,
  6. bool frozen = false,
  7. DateTime? lastMessageAt,
  8. DateTime? createdAt,
  9. DateTime? updatedAt,
  10. DateTime? deletedAt,
  11. int memberCount = 0,
  12. Map<String, Object?> extraData = const {},
  13. String? team,
  14. int cooldown = 0}
)

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();