WidgetChat class
Conversation model containing metadata and chat messages.
Constructors
-
WidgetChat({required int id, required String customerId, required String name, required String status, required int? assigneeId, required bool isChatWithAi, required String? avatarUrl, required String avatarInitials, required List<
WidgetMessage> messages, bool surveyPending = false, int? surveyRating, String? surveyComment, int? customerLastReadMessageId, bool hasServerReadState = false}) -
Creates an immutable chat model.
const
-
WidgetChat.fromJson(Map<
String, dynamic> json) -
Creates a WidgetChat from backend JSON data.
factory
Properties
- assigneeId → int?
-
Assigned human agent ID when present.
final
- avatarInitials → String
-
Initials fallback used when no avatar image exists.
final
- avatarUrl → String?
-
Optional avatar URL for chat header/list.
final
- customerId → String
-
Backend customer identifier for this conversation.
final
- customerLastReadMessageId → int?
-
Last message id the customer has read, as stored by the backend
(
customer_last_read_message_id); null when nothing has been read.final - hashCode → int
-
The hash code for this object.
no setterinherited
- hasHumanAssignee → bool
-
Returns true when the chat has an assigned human and is not AI-only.
no setter
- hasServerReadState → bool
-
Whether the backend tracks the customer's read position for this chat
(the field is present in the payload). Older backends omit it.
final
- id → int
-
Internal numeric chat identifier.
final
- isChatWithAi → bool
-
Whether the chat is currently handled by AI.
final
- isFinished → bool
-
True once the conversation has ended (
resolved, or the legacyclosed): the composer gives way to the "start new chat" banner.no setter -
messages
→ List<
WidgetMessage> -
Messages sorted by backend response order.
final
- name → String
-
Display title shown in the chat list.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → String
-
Current backend status of the chat.
final
- surveyComment → String?
-
Optional saved survey comment on the chat.
final
- surveyPending → bool
-
Customer still owes a CSAT response (API + in-thread survey invite).
final
- surveyRating → int?
-
Saved 1–5 rating on the chat after submission.
final
Methods
-
copyWith(
{List< WidgetMessage> ? messages, String? status, int? assigneeId, bool? isChatWithAi, String? name, String? avatarUrl, String? avatarInitials, bool? surveyPending, int? surveyRating, String? surveyComment}) → WidgetChat - Returns a new instance with selectively replaced fields.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withAssignee(
int? assigneeId, {String? avatarUrl}) → WidgetChat -
Copy with
assigneeIdandavatarUrlset exactly, including to null (which copyWith cannot express).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited