copyWith method

ChatState copyWith({
  1. ChatPhase? phase,
  2. HatangConnectionState? connection,
  3. SiteConfig? config,
  4. VisitorDto? visitor,
  5. ConversationSummary? conversation,
  6. Timeline? timeline,
  7. List<PendingMessage>? pending,
  8. String? typingAgent,
  9. Availability? availability,
  10. int? unread,
  11. HatangLocale? locale,
  12. bool? needsEmail,
  13. bool? skippedEmail,
  14. int? rated,
  15. HatangException? transientError,
  16. String? outdatedReason,
  17. String? visitorEmail,
  18. String? visitorName,
  19. bool? loadingEarlier,
  20. bool? visible,
  21. bool? foreground,
  22. String? draft,
  23. bool clearConversation = false,
  24. bool clearTyping = false,
  25. bool clearError = false,
  26. bool clearDraft = false,
  27. bool clearRated = false,
})

Copies with some fields replaced; clear* flags null a field.

Implementation

ChatState copyWith({
  ChatPhase? phase,
  HatangConnectionState? connection,
  SiteConfig? config,
  VisitorDto? visitor,
  ConversationSummary? conversation,
  Timeline? timeline,
  List<PendingMessage>? pending,
  String? typingAgent,
  Availability? availability,
  int? unread,
  HatangLocale? locale,
  bool? needsEmail,
  bool? skippedEmail,
  int? rated,
  HatangException? transientError,
  String? outdatedReason,
  String? visitorEmail,
  String? visitorName,
  bool? loadingEarlier,
  bool? visible,
  bool? foreground,
  String? draft,
  bool clearConversation = false,
  bool clearTyping = false,
  bool clearError = false,
  bool clearDraft = false,
  bool clearRated = false,
}) => ChatState(
  phase: phase ?? this.phase,
  connection: connection ?? this.connection,
  config: config ?? this.config,
  visitor: visitor ?? this.visitor,
  conversation: clearConversation ? null : (conversation ?? this.conversation),
  timeline: timeline ?? this.timeline,
  pending: pending ?? this.pending,
  typingAgent: clearTyping ? null : (typingAgent ?? this.typingAgent),
  availability: availability ?? this.availability,
  unread: unread ?? this.unread,
  locale: locale ?? this.locale,
  needsEmail: needsEmail ?? this.needsEmail,
  skippedEmail: skippedEmail ?? this.skippedEmail,
  rated: clearRated ? null : (rated ?? this.rated),
  transientError: clearError ? null : (transientError ?? this.transientError),
  outdatedReason: outdatedReason ?? this.outdatedReason,
  visitorEmail: visitorEmail ?? this.visitorEmail,
  visitorName: visitorName ?? this.visitorName,
  loadingEarlier: loadingEarlier ?? this.loadingEarlier,
  visible: visible ?? this.visible,
  foreground: foreground ?? this.foreground,
  draft: clearDraft ? null : (draft ?? this.draft),
);