fix customize_channel_preview example

This commit is contained in:
Salvatore Giordano
2021-01-19 12:12:28 +01:00
parent 2931fb2d4c
commit 7fce7ebf38
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
c770358a10272b4ee1cdc2eb432445f6
c1153e968f5d6bcc19c41ac2592825f6
+5 -3
View File
@@ -62,7 +62,7 @@ class ChannelListPage extends StatelessWidget {
}
},
channelPreviewBuilder: _channelPreviewBuilder,
sort: [SortOption('last_message_at')],
// sort: [SortOption('last_message_at')],
pagination: PaginationParams(
limit: 20,
),
@@ -73,8 +73,10 @@ class ChannelListPage extends StatelessWidget {
}
Widget _channelPreviewBuilder(BuildContext context, Channel channel) {
final lastMessage = channel.state.messages.reversed
.firstWhere((message) => !message.isDeleted);
final lastMessage = channel.state.messages.reversed.firstWhere(
(message) => !message.isDeleted,
orElse: () => null,
);
final subtitle = (lastMessage == null ? "nothing yet" : lastMessage.text);
final opacity = channel.state.unreadCount > .0 ? 1.0 : 0.5;