ChatItemQuote.from constructor

ChatItemQuote.from(
  1. ChatItem item
)

Constructs a ChatItemQuote from the provided ChatItem.

Implementation

factory ChatItemQuote.from(ChatItem item) {
  if (item is ChatMessage) {
    return ChatMessageQuote(
      author: item.author.id,
      at: item.at,
      attachments: item.attachments,
      text: item.text,
      original: item,
    );
  } else if (item is ChatCall) {
    return ChatCallQuote(author: item.author.id, at: item.at, original: item);
  } else if (item is ChatInfo) {
    return ChatInfoQuote(
      author: item.author.id,
      at: item.at,
      action: item.action,
      original: item,
    );
  } else if (item is ChatForward) {
    return item.quote;
  }

  throw Exception('$item is not supported to be quoted');
}