loop_sdk 0.2.1 copy "loop_sdk: ^0.2.1" to clipboard
loop_sdk: ^0.2.1 copied to clipboard

unlisted

Loop SDK for Flutter

Usage #

To integrate LoopFlow into your Flutter application, follow these steps:

Step 1: Add the dependency #

Add the Loop SDK dependency to your pubspec.yaml file:


dependencies:

loop_sdk: ^0.2.1

Step 2: Initialize the Loop SDK #

Initialize the Loop SDK with your credentials:

import 'package:loop_sdk/loop_sdk.dart';
import 'package:loop_sdk/Environment.dart';

LoopSDK.initialize(
userId: "<userId>",
accessKey: "<accesskey>",
userAuthToken: "<userAuthToken>",
environment: Environment.PRODUCTION,
);

Trigger LoopFlow when needed #

Use the following code snippet to trigger the LoopFlow:

Use the loopEventHandler and customEventHandler to handle the events.

import 'package:loop_sdk/loop_event.dart';
import 'package:loop_sdk/loop_pod.dart';
LoopSDK.show(
	context: context,
	campaignId: "<campaignID>",
	campaignKey: <campaignKey>,
	extraParams: const {
		"param1": "somevalue",
		"param2": "65cb3919somevalue7c7436442b3fb0ec"
	},
	loopEventHandler: (event, params) {
	switch (event) {
		case LoopEvent.ON_FLOW_START:
			// 'Handle flow start here
			break;
		case LoopEvent.ON_FLOW_END:
			// Handle flow ended
			break;
		case LoopEvent.ON_FLOW_DISMISS:
			// Handle Flow dismissed
			break;
		}
	},
	customEventHandler: (eventName, params) {
		//Handle Custom Event: $eventName
	},
	disableFlowEndNavigation: false,
	disableDeviceBack: false,
);

LoopPod #

Loop pod is the component you can embed which will act as an entry point to journeys like Banners, carousel etc. LoopPod does not require any triggers.

import 'package:loop_sdk/loop_event.dart';
import 'package:loop_sdk/loop_pod.dart';
LoopPod(
	podId:  <podId>,
	type: "inline" | "overlay"
	loopEventHandler: (event, params) {
		switch (event) {
			case  LoopEvent.ON_FLOW_START:
				print('Handle Flow started');
				break;
			case  LoopEvent.ON_FLOW_END:
				print('Handle Flow ended');
				break;
			case  LoopEvent.ON_FLOW_DISMISS:
				print('Handle Flow dismissed');
				break;
			case  LoopEvent.ON_FLOW_SWITCH:
				print('Handle Flow switch $params');
				break;
			case  LoopEvent.ON_FLOW_RESIZE:
				break;
		}
		print('Event: $event');
	},
	customEventHandler: (eventName, params) {
		print('Custom Event: $eventName');
		print('Custom Event Params: $params');
	},
)

Ensure you replace placeholders such as userId, accesskey , etc., with actual values from your Loop configuration.

The new update provides:

  • Support for overlay pod.
  • Ensure to pass the "type" parameter in LoopPod Widget as above.
  • type = "overlay" => renders the pod as an overlay screen.
  • type = "inline" => renders the pod as an inline widget.
  • If not mentioned, pod defaults to inline