ChannelEvent.fromJson constructor

ChannelEvent.fromJson(
  1. Map<String, dynamic> json
)

Create from JSON.

Implementation

factory ChannelEvent.fromJson(Map<String, dynamic> json) {
  return ChannelEvent(
    id: json['id'] as String,
    conversation:
        ConversationKey.fromJson(json['conversation'] as Map<String, dynamic>),
    type: json['type'] as String,
    text: json['text'] as String?,
    userId: json['userId'] as String?,
    userName: json['userName'] as String?,
    timestamp: DateTime.parse(json['timestamp'] as String),
    attachments: (json['attachments'] as List<dynamic>?)
        ?.map((e) => ChannelAttachment.fromJson(e as Map<String, dynamic>))
        .toList(),
    metadata: json['metadata'] as Map<String, dynamic>?,
  );
}