Skip to main content

How to render feed for a particular topic?

Introduction

In this guide, you'll learn how to render feed for a particular topic using the LikeMinds Feed Flutter SDK. LMFeedList widget can be used to render feed with a particular topic.

Prerequisites

Before you begin, ensure the following:

  • LikeMinds Feed Flutter SDK: The SDK must be properly installed and initialized in your Flutter project. Refer to the installation guide if needed.
  • Feed Enabled: Ensure that Feed is enabled on the dashboard for your project.
  • Basic Understanding of Flutter Widgets: Familiarity with Flutter widgets and layout concepts.
  • Knowledge of Builder Pattern: Understanding of the builder pattern in Dart, as it is used to customize and create widgets dynamically.
  • Familiarity with copyWith Method: Knowledge of the copyWith method, which allows you to create modified copies of objects while retaining their original properties.

Steps

Step 1: Create a new screen using Scaffold widget to utilize LMFeedList widget.

class LMTopicFeed extends StatelessWidget {
LMTopicFeed({
super.key,
required this.selectedIds,
});
// List to store selected topic ids
final List<String> selectedIds;

// create a pagingController to pass in LMFeedList
final pagingController =
PagingController<int, LMPostViewData>(firstPageKey: 1);

Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Topic Feed'),
),
body: CustomScrollView(
slivers: [
LMFeedList(
selectedTopicIds: selectedIds,
pagingController: pagingController,
),
],
),
);
}
}

Step 2: Navigate to above create Topic Feed Screen

  // create a route to topic feed with selected topic ids
final topicFeedRoute = MaterialPageRoute(
builder: (context) => LMTopicFeed(
selectedIds: ["TOPIC_ID"],
),
);

// navigate to topic feed screen
Navigator.push(context, topicFeedRoute);