Skip to main content

Getting Started

The LikeMinds Flutter Feed SDK empowers you to integrate personalized and engaging feeds into your Flutter application, enhancing user experiences and driving user engagement. This guide will walk you through the steps to get started with the LikeMinds Flutter Feed SDK and set up a dynamic feed in your application. Obtain the necessary API key from the LikeMinds dashboard.

Add Dependency

Add likeminds_feed as a dependency in your pubspec.yaml file

dependencies:
likeminds_feed: ^latest

or you can run this command in the terminal

flutter pub add likeminds_feed

Usage

To start using the package, import it in your main.dart file

import 'package:likeminds_feed/likeminds_feed.dart';

To initiate LikeMinds SDK in your code, use the LMFeedClientBuilder class to build an instance of the LMFeedClient class. The LMFeedClientBuilder class has a build() method that returns the LMFeedClient instance.

// Initiate the LMFeedClient instance
final LMFeedClient lmFeedClient = (LMFeedClientBuilder()
..sdkCallback(YOUR_CALLBACK))
.build();
tip

Maintain this instance of the LMFeedClient class throughout your application. You can use it to access the different methods exposed by the package.

LMSDKCallback

The LMSDKCallback class is a callback class that is used to listen to analytic events from the LikeMinds Feed package. It has several methods that you can override to listen to events from the package.

class YourCallback extends LMChatSDKCallback {

void eventFiredCallback(String eventKey, Map<String, dynamic> propertiesMap) {
// Implement eventFiredCallback
print('Event Fired: $eventKey with properties: $propertiesMap');
}


void loginRequiredCallback() {
print('Login required');
}


void logoutCallback() {
print('User logged out');
}


void profileRouteCallback({required String lmUserId}) {
print('Profile button clicked for user: $lmUserId');
}


void onAccessTokenExpiredAndRefreshed(String accessToken, String refreshToken) {
print('Access token refreshed: $accessToken');
}


Future<LMAuthToken> onRefreshTokenExpired() async {
print('Refresh token expired, fetching new token...');
return LMAuthToken(accessToken: 'newAccessToken', refreshToken: 'newRefreshToken');
}
}