asItems property

List<ChatItem> get asItems

Returns the ChatItems this list of ListElement represents.

Implementation

List<ChatItem> get asItems {
  final List<ChatItem> items = [];

  for (var e in this) {
    if (e is ChatMessageElement) {
      items.add(e.item.value);
    } else if (e is ChatCallElement) {
      items.add(e.item.value);
    } else if (e is ChatInfoElement) {
      items.add(e.item.value);
    } else if (e is ChatForwardElement) {
      if (e.note.value != null) {
        items.add(e.note.value!.value);
      }

      for (var f in e.forwards) {
        items.add(f.value);
      }
    }
  }

  return items;
}