From 21a2ec5b2f22899db0aac624533b70060ba53f31 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Sat, 23 May 2020 08:36:53 +0000 Subject: [PATCH] handle if lastEvent is null --- lib/components/list_items/chat_list_item.dart | 13 +++++++------ lib/views/chat_list.dart | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/components/list_items/chat_list_item.dart b/lib/components/list_items/chat_list_item.dart index 5e340c0..7d54815 100644 --- a/lib/components/list_items/chat_list_item.dart +++ b/lib/components/list_items/chat_list_item.dart @@ -184,16 +184,17 @@ class ChatListItem extends StatelessWidget { softWrap: false, ) : Text( - room.lastEvent.getLocalizedBody( - L10n.of(context), - withSenderNamePrefix: !room.isDirectChat, - hideReply: true, - ), + room.lastEvent?.getLocalizedBody( + L10n.of(context), + withSenderNamePrefix: !room.isDirectChat, + hideReply: true, + ) ?? + '', softWrap: false, maxLines: 1, overflow: TextOverflow.fade, style: TextStyle( - decoration: room.lastEvent.redacted + decoration: room.lastEvent?.redacted == true ? TextDecoration.lineThrough : null, ), diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index fcbddfb..4914ae8 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -384,10 +384,11 @@ class _ChatListState extends State { var rooms = List.from( Matrix.of(context).client.rooms); rooms.removeWhere((Room room) => - searchMode && - !room.displayname.toLowerCase().contains( - searchController.text.toLowerCase() ?? - '')); + room.lastEvent == null || + (searchMode && + !room.displayname.toLowerCase().contains( + searchController.text.toLowerCase() ?? + ''))); if (rooms.isEmpty && (!searchMode || publicRoomsResponse == null)) {