flutterdartgetstream-iogetstream-chat

StreamUnreadIndicator does not update and displays nothing getStream Api


I have had tough luck with the StreamUnreadIndicator() within the getStream API. I am trying to essentially have an indicator on the list tile for whenever a new message comes in. But nothing returns. I tried putting some debug prints to at least get the number of unread messages for the channel, but it is always 0.

Here's my message list view:

Widget _messagesList(List<dynamic>? messages, StreamChatClient client,
      int messageCount, bool friendsTab) {
    return ListView.separated(
      keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
      itemCount: messageCount,
      itemBuilder: (context, index) {
        //print("messaging:"+messages![index].channel);
        return GestureDetector(
          onTap: () {
            Navigator.of(context).push(MaterialPageRoute(builder: (context) =>
                MessageApi(
                  sourceType: SourceType.justMet,
                  receiverUser: friendsTab ? friends[index] : chatRequesters[index],
                  userName: userName,
                  channelId: messages![index].channel,
                  streamToken: streamToken,
                  client: StreamChatCore.of(context).client,
                )
            ));
          },
          child: ListTile(
            title: friendsTab ? Text(friends[index].firstName) : Text(chatRequesters[index].firstName),
            subtitle: _buildLastMessage(messages![index].channel, client),
            trailing: Column(
              children: [
                StreamUnreadIndicator(
                  cid: "messaging:"+messages[index].channel,
                ),
                _buildLastMessageAt(messages[index].channel, client),
              ],
            ),
            leading: CircleAvatar(
              radius: 30,
              backgroundImage: CachedNetworkImageProvider(
                  friendsTab ? friends[index].photoUrl : chatRequesters[index].photoUrl
              ),
            ),
          ),
        );
      },
      separatorBuilder: (context, index) {
        return const Divider();
      },
    );
  }

Solution

  • They seem to have updated their backend and now it works without me changing anything. I noticed they changed their docs recently too after this question.