Skip to main content

Getting Started

The LikeMinds Flutter Feed SDK provides a robust solution to seamlessly integrate dynamic and engaging feed experiences into your Flutter application. This guide walks you through setting up the LikeMinds Flutter Feed SDK, empowering you to deliver personalized content efficiently. Obtain the necessary API key from the LikeMinds dashboard.

Prerequisites

Before getting started, ensure you have:

  1. Flutter Version: Your Flutter version should be 3.19.0 or higher.

Step-by-Step Integration Guide

Follow these steps to integrate the LikeMinds Feed SDK into your Flutter application:

Step 1 - Installation

Open the terminal, and run the following command in your Flutter project's directory.

flutter pub add likeminds_feed_flutter_core

Step 2 - Setup LikeMinds Feed

After setting up the SDK, you must initialize the Feed module before using any LMFeedCore widgets, screens, or functions. This is the entry point to configure themes, logging, listeners, and system UI styles for your feed experience.

Call the initialize() method during your app’s startup.

Here are the parameters available:

VARIABLETYPEDESCRIPTIONOPTIONAL
domainStringThe domain associated with your LikeMinds Feed instance.
configLMFeedConfigConfiguration options to control feed features and behavior.
themeLMFeedThemeDataCustom theming options for the feed UI (colors, fonts, etc.).
analyticsListenerFunction(LMFeedAnalyticsEventFired)Callback to listen to analytics events triggered within the feed.
profileListenerFunction(LMFeedProfileState)Callback for receiving updates to the current user’s profile state.
lmFeedCallbackLMFeedCoreCallbackSDK callback interface for listening to events like errors or initialization status.
systemUiOverlayStyleSystemUiOverlayStyleOptional system UI styling to be applied when the feed is active.
loggingRequestInitiateLoggerRequestOptional object to enable SDK logging. If not provided, default logging is enabled. The coreVersion field is set automatically and should not be overridden.

Setup the LMFeedCore package in the main function with the following code

main(){
WidgetsFlutterBinding.ensureInitialized();
// Call setup function before the runApp() function
final LMFeedConfig config = LMFeedConfig(
feedThemeType: LMFeedThemeType.socialFeed,
);
// Optional custom theme
final LMFeedThemeData theme = LMFeedThemeData.light();

// Optional parameters
final Function(LMFeedAnalyticsEventFired)? analyticsListener = null;
final Function(LMFeedProfileState)? profileListener = null;
final LMFeedCoreCallback? lmFeedCallback = null;
final SystemUiOverlayStyle? systemUiOverlayStyle = null;
final InitiateLoggerRequest? loggingRequest = null;

// Initialize LikeMinds Feed SDK
await LMFeedCore.instance.initialize(
domain: "ENTER YOUR DOMAIN NAME",
config: config,
theme: theme,
analyticsListener: analyticsListener,
profileListener: profileListener,
lmFeedCallback: lmFeedCallback,
systemUiOverlayStyle: systemUiOverlayStyle,
loggingRequest: loggingRequest,
);
...
runApp(YourApp());
}

Step 3 - Initiate User Session

You have successfully initiated the LMFeedCore. Now, you have to initiate a user session. Provide API Key directly to LikeMinds Feed SDK, which will be used to initiate a user session by calling LMFeedCore.showFeedWithApiKey().

// initiate user session, use the response to check for any errors
LMResponse<void> response = await LMFeedCore.instance.showFeedWithApiKey(
apiKey : "YOUR_API_KEY",
uuid : "USER_ID",
userName : "USER_NAME",
);

tip

For enhanced security, you can use Server Side User Authentication to initiate user sessions through your own server.

Step 4 - Navigation to the feed

On successful response of the above snippet you can simply navigate to the Feed Screen, and start using Feed in your app


if (response.success) {
// create route with LMFeedSocialScreen
MaterialPageRoute route = MaterialPageRoute(
builder: (context) => const LMFeedSocialScreen(),
);
// navigate to LMFeedSocialScreen
Navigator.pushReplacement(context, route);
}

tip

By choosing the appropriate method based on your backend infrastructure and security preferences, you can seamlessly integrate the Feed SDK into your application while ensuring secure and efficient session management.

Congratulations! Your integration is now complete.

Welcome to the future of digital communities and social networks.


LMFeedAppbar