copyWith method

ChannelModel copyWith({
  1. String? id,
  2. String? type,
  3. String? cid,
  4. List<String>? ownCapabilities,
  5. ChannelConfig? config,
  6. User? createdBy,
  7. bool? frozen,
  8. DateTime? lastMessageAt,
  9. DateTime? createdAt,
  10. DateTime? updatedAt,
  11. DateTime? deletedAt,
  12. int? memberCount,
  13. Map<String, Object?>? extraData,
  14. String? team,
  15. int? cooldown,
  16. bool? disabled,
  17. bool? hidden,
  18. DateTime? truncatedAt,
})

Creates a copy of ChannelModel with specified attributes overridden.

Implementation

ChannelModel copyWith({
  String? id,
  String? type,
  String? cid,
  List<String>? ownCapabilities,
  ChannelConfig? config,
  User? createdBy,
  bool? frozen,
  DateTime? lastMessageAt,
  DateTime? createdAt,
  DateTime? updatedAt,
  DateTime? deletedAt,
  int? memberCount,
  Map<String, Object?>? extraData,
  String? team,
  int? cooldown,
  bool? disabled,
  bool? hidden,
  DateTime? truncatedAt,
}) =>
    ChannelModel(
      id: id ?? this.id,
      type: type ?? this.type,
      cid: cid ?? this.cid,
      ownCapabilities: ownCapabilities ?? this.ownCapabilities,
      config: config ?? this.config,
      createdBy: createdBy ?? this.createdBy,
      frozen: frozen ?? this.frozen,
      lastMessageAt: lastMessageAt ?? this.lastMessageAt,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
      deletedAt: deletedAt ?? this.deletedAt,
      memberCount: memberCount ?? this.memberCount,
      extraData: extraData ?? this.extraData,
      team: team ?? this.team,
      cooldown: cooldown ?? this.cooldown,
      disabled: disabled ?? extraData?['disabled'] as bool? ?? this.disabled,
      hidden: hidden ?? extraData?['hidden'] as bool? ?? this.hidden,
      truncatedAt: truncatedAt ??
          (extraData?['truncated_at'] == null
              ? null
              // ignore: cast_nullable_to_non_nullable
              : DateTime.parse(extraData?['truncated_at'] as String)) ??
          this.truncatedAt,
    );