Skip to main content

How to Filter Chatroom based on Tags?

Introduction

This guide explains how to filter the home feed based on tags using the LikeMinds Chat Flutter SDK. This is useful when you want to add custom tags to your chatroom. And filter the home feed based on these tags. Only the tags passed while initializing the LMChatCore will be used for filtering.

Prerequisites

Before you begin, ensure the following:

  • LikeMinds Chat Flutter SDK: The SDK must be properly installed and initialized in your Flutter project. Refer to the installation guide if needed.
  • Basic Understanding of Flutter: Familiarity with Flutter widgets and navigation.

Steps to Add Tags and Filter the List

Step 1: Setup Chatroom Tags

To setup the chatroom tags, you can use our API. Before you can use the API, you need to get the AUTH-TOKEN for the user. You can set this up using the following Authentication guide.

Using the snippet below and the cURL request, you can setup the chatroom tags using the API.

curl --location --request PUT 'https://auth.likeminds.community/chatroom' \
--header 'Authorization: <AUTH-TOKEN>' \
--header 'x-platform-type: dashboard' \
--header 'Content-Type: application/json' \
--data '{
"chatroom_id": <CHATROOM-ID>,
"tag": "<YOUR-TAG-HERE>"
}'

Step 2: Configure Chatroom Tags in SDK

While initializing the SDK, pass the tags you want to filter the home feed by. This can be done by passing the LMChatHomeConfig in the LMChatConfig object to the initialize method. The configuration classes are available in the likeminds_chat_core package.

LMFeedCore.instance.initialize(
config: LMChatConfig(
homeConfig: const LMChatHomeConfig(
setting: LMChatHomeSetting(tag: "YOUR-TAG-HERE"),
),
),
);

Optionally, you can also pass the chatroom tag parameter in the LMChatHomeFeedList widget. This will filter the home feed based on the tag passed.

LMChatHomeFeedList(
chatroomTag: "YOUR-TAG-HERE",
);

This completes the setup for using custom chatroom tags within the SDK.