Get Group Chatrooms
The Home Feed is a vital component of many applications, providing users with a centralized hub to discover and engage with various content, including chatrooms, discussions, and other interactive features. In the context of the Flutter SDK, the Home Feed serves as a customizable and dynamic feed that can be tailored to suit your application's needs.
This guide provide step-by-step instructions, code snippets, and best practices for integrating the Home Feed and fetching community chatrooms in your Flutter app.
Let's dive into the world of Home Feed integration with the Flutter SDK and unlock the potential for vibrant chatroom communities within your application.
Steps to Get Group Chatrooms
- Create an object of the
GetHomeFeedRequest
class. - Call the
getHomeFeed()
function using the instance of theLMChatClient
class. - Process the response LMResponse<
GetHomeFeedResponse
> as per your requirement.
GetHomeFeedRequest request = (GetHomeFeedRequestBuilder()
..page(1) // Specify the page number
..pageSize(20) // Set the page size
..minTimestamp(1627683600) // Minimum timestamp
..maxTimestamp(1627770000) // Maximum timestamp
..chatroomTypes([0, 7]) // Specify chatroom types
..tag('tag_name') // Add a tag filter
..isLocalDb(true)) // Use local database
.build();
final LMResponse<GetHomeFeedResponse> response =
await lmChatClient.getHomeFeed(request);
if (response.success) {
// Handle the home feed response
GetHomeFeedResponse homeFeed = response.data!;
handleHomeFeed(homeFeed);
} else {
// Handle error
handleError(response);
}
Models
GetHomeFeedRequest
List of parameters for the GetHomeFeedRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
page | int | Page number for paginated response | |
pageSize | int? | Page size for paginated response | ✔️ |
minTimestamp | int? | Minimum timestamp for filtering | ✔️ |
maxTimestamp | int? | Maximum timestamp for filtering | ✔️ |
chatroomTypes | List<int>? | List of chatroom types to filter | ✔️ |
tag | String? | The tag filter for the home feed | ✔️ |
isLocalDb | bool | Flag to indicate local DB usage | ✔️ |
GetHomeFeedResponse
List of parameters for the GetHomeFeedResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
communityMeta | Map<String, Community>? | Map of communities with their ID as the key | ✔️ |
chatroomsData | List<ChatRoom>? | List of chatrooms | ✔️ |
conversationMeta | Map<String, Conversation>? | Map of conversations with their ID as the key | ✔️ |
userMeta | Map<int, User>? | Map of users with their ID as the key | ✔️ |
cardAttachmentsMeta | Map<String, Attachment>? | Map of card attachments | ✔️ |
conversationAttachmentsMeta | Map<String, List<Attachment>? | Map of conversation attachments with their ID as the key | ✔️ |
conversationPollsMeta | Map<dynamic, dynamic>? | Map of conversation polls | ✔️ |