clevertap_plugin 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

CleverTap Flutter SDK #

The CleverTap Flutter SDK for Mobile Customer Engagement and Analytics solutions

CleverTap brings together real-time user insights, an advanced segmentation engine, and easy-to-use marketing tools in one mobile marketing platform — giving your team the power to create amazing experiences that deepen customer relationships. Our intelligent mobile marketing platform provides the insights you need to keep users engaged and drive long-term retention and growth.

For more information check out our website and documentation.

Install and Integration #

To add the CleverTap Flutter SDK to your project, edit your project's pubspec.yaml file:

    dependencies:
    clevertap_plugin: 1.1.1

Run flutter packages get to install the SDK

Now, in your Dart code, you can use :

    import 'package:clevertap_plugin/clevertap_plugin.dart';

Android #

Add the following to your dependencies section in project/build.gradle

    dependencies {
            classpath 'com.android.tools.build:gradle:3.5.1'
            classpath 'com.google.gms:google-services:4.3.2' //<--- Mandatory for using Firebase Messaging, skip if not using FCM
        }

Add the following to your dependencies section in app/build.gradle

    implementation 'com.clevertap.android:clevertap-android-sdk:3.7.2'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.google.firebase:firebase-messaging:17.3.4'//Mandatory for using FCM push notifications, skip if not using FCM
        implementation 'com.android.support:appcompat-v7:28.0.0'//MANDATORY for App Inbox
        implementation 'com.android.support:design:28.0.0'//MANDATORY for App Inbox
        implementation 'com.github.bumptech.glide:glide:4.9.0'//MANDATORY for App Inbox
    //For CleverTap Android SDK v3.6.4 and above add the following -
        implementation 'com.android.installreferrer:installreferrer:1.0'
    //Optional ExoPlayer Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies
        implementation 'com.google.android.exoplayer:exoplayer:2.8.4'
        implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.4'
        implementation 'com.google.android.exoplayer:exoplayer-ui:2.8.4'

At the end of the app/build.gradle file add the following

    apply plugin: 'com.google.gms.google-services' //skip if not using FCM

In your app's Android Application class add the following code.

    public class MyApplication extends FlutterApplication {
        @java.lang.Override
        public void onCreate() {
            ActivityLifecycleCallback.register(this); //<--- Add this before super.onCreate()
            super.onCreate();
        }
    }

If you do not have an Application class, add this to your AndroidManifest.xml

    <application
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:name="com.clevertap.android.sdk.Application"> 

Add the following permissions which are needed by the CleverTap SDK

    <!-- Required to allow the app to send events and user profile information -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- Recommended so that CleverTap knows when to attempt a network call -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Add your CleverTap Account ID and Token to your AndroidManifest.xml, within the tags.

    <meta-data
        android:name="CLEVERTAP_ACCOUNT_ID"
        android:value="Your CleverTap Account ID"/>
    <meta-data
        android:name="CLEVERTAP_TOKEN"
        android:value="Your CleverTap Account Token"/>
    <!-- IMPORTANT: To force use Google AD ID to uniquely identify  users, use the following meta tag. GDPR mandates that if you are using this tag, there is prominent disclousure to your end customer in their application. Read more about GDPR here - https://clevertap.com/blog/in-preparation-of-gdpr-compliance/ -->
    <meta-data
        android:name="CLEVERTAP_USE_GOOGLE_AD_ID"
        android:value="1"/> 

iOS #

After install, you will need to integrate the CleverTap SDK into your apps.

  1. Follow the integration instructions starting with Step 2 here.
  2. In your AppDelegate didFinishLaunchingWithOptions: notify the CleverTap Flutter SDK of application launch:
[CleverTap autoIntegrate]; // integrate CleverTap SDK using the autoIntegrate option
[[CleverTapPlugin sharedInstance] applicationDidLaunchWithOptions:launchOptions];

NOTE: Don't forget to add the CleverTap imports at the top of the file.

#import "CleverTap.h"
#import "CleverTapPlugin.h"

Example Dart Usage #

Please checkout the example directory for the sample app.

For more: #

For more information you can checkout the developer docs

CHANGE LOG #

Version 1.1.1 (March 30, 2020) #

  • Adds support for Custom App Inbox
  • Adds support for InApp/Inbox button click listeners
  • Adds support for Notification Clicked/Viewed for App Inbox
  • Adds support for passing Xiaomi/Baidu tokens.
  • Supports CleverTap Android SDK v3.7.2
  • Supports CleverTap iOS SDK v3.7.3

Version 1.1.0 (February 27, 2020) #

  • Adds support for Dynamic Variables & Native Display
  • Adds support for Google Play Install Referrer Library v1.0
  • Supports CleverTap Android SDK v3.6.4
  • Supports CleverTap iOS SDK v3.7.2

Version 1.0.0 (January 20, 2020) #

  • Initial Release.
  • Supports CleverTap Android SDK v3.6.1
  • Supports CleverTap iOS SDK v3.7.2

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io' show Platform;

import 'package:clevertap_plugin/clevertap_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  CleverTapPlugin _clevertapPlugin;
  var inboxInitialized = false;
  var optOut = false;
  var offLine = false;
  var enableDeviceNetworkingInfo = false;

  @override
  void initState() {
    super.initState();
    initPlatformState();
    activateCleverTapFlutterPluginHandlers();
    CleverTapPlugin.setDebugLevel(3);
    CleverTapPlugin.createNotificationChannel("fluttertest", "Flutter Test", "Flutter Test", 3, true);
    CleverTapPlugin.initializeInbox();
    CleverTapPlugin.registerForPush();
    var initialUrl = CleverTapPlugin.getInitialUrl();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    if (!mounted) return;
  }

  void activateCleverTapFlutterPluginHandlers(){
    _clevertapPlugin = new CleverTapPlugin();
    _clevertapPlugin.setCleverTapInAppNotificationDismissedHandler(inAppNotificationDismissed);
    _clevertapPlugin.setCleverTapProfileDidInitializeHandler(profileDidInitialize);
    _clevertapPlugin.setCleverTapProfileSyncHandler(profileDidUpdate);
    _clevertapPlugin.setCleverTapInboxDidInitializeHandler(inboxDidInitialize);
    _clevertapPlugin.setCleverTapInboxMessagesDidUpdateHandler(inboxMessagesDidUpdate);
    _clevertapPlugin.setCleverTapExperimentsDidUpdateHandler(ctExperimentsUpdated);
    _clevertapPlugin.setCleverTapDisplayUnitsLoadedHandler(onDisplayUnitsLoaded);
    _clevertapPlugin.setCleverTapInAppNotificationButtonClickedHandler(inAppNotificationButtonClicked);
    _clevertapPlugin.setCleverTapInboxNotificationButtonClickedHandler(inboxNotificationButtonClicked);
  }

  void inAppNotificationDismissed(Map<String,dynamic> map){
    this.setState((){
      print("inAppNotificationDismissed called");
    });
  }

  void inAppNotificationButtonClicked(Map<String,dynamic> map){
    this.setState((){
      print("inAppNotificationButtonClicked called = ${map.toString()}");
    });
  }

  void inboxNotificationButtonClicked(Map<String,dynamic> map){
    this.setState((){
      print("inboxNotificationButtonClicked called = ${map.toString()}");
    });
  }

  void profileDidInitialize(){
    this.setState((){
      print("profileDidInitialize called");
    });
  }

  void profileDidUpdate(Map<String,dynamic> map){
    this.setState((){
      print("profileDidUpdate called");
    });
  }

  void inboxDidInitialize(){
    this.setState((){
      print("inboxDidInitialize called");
      inboxInitialized = true;
    });
  }

  void inboxMessagesDidUpdate(){
    this.setState(() async {
      print("inboxMessagesDidUpdate called");
      int unread = await CleverTapPlugin.getInboxMessageUnreadCount();
      int total = await CleverTapPlugin.getInboxMessageCount();
      print("Unread count = "+unread.toString());
      print("Total count = "+total.toString());
    });
  }

  void ctExperimentsUpdated(){
    this.setState(() async {
      print("CTExperimentsUpdated called");
      bool booleanVar = await CleverTapPlugin.getBooleanVariable("boolVar", false);
      print("Boolean var = " + booleanVar.toString());
      double doubleVar = await CleverTapPlugin.getDoubleVariable("doubleVar", 9.99);
      print("Double var = " + doubleVar.toString());
      int integerVar = await CleverTapPlugin.getIntegerVariable("integerVar", 999);
      print("Integer var = "+integerVar.toString());
      String stringVar = await CleverTapPlugin.getStringVariable("stringVar", "defaultString");
      print("String var = "+stringVar.toString());
      List<dynamic> boolList = await CleverTapPlugin.getListOfBooleanVariable("boolListVar", null);
      print("List of bool = "+boolList.toString());
      List<dynamic> doubleList = await CleverTapPlugin.getListOfDoubleVariable("doubleListVar", null);
      print("List of double = "+doubleList.toString());
      List<dynamic> intList = await CleverTapPlugin.getListOfIntegerVariable("integerListVar", null);
      print("Integer List = "+intList.toString());
      List<dynamic> stringList = await CleverTapPlugin.getListOfStringVariable("stringListVar", null);
      print("String List = "+stringList.toString());
//      Map<String,bool> boolMap = await CleverTapPlugin.getMapOfBooleanVariable("boolMapVar", null);
//      print("Map of bool = "+boolMap.toString());
//      Map<String,double> doubleMap = await CleverTapPlugin.getMapOfDoubleVariable("doubleMapVar", null);
//      print("Map of double = "+doubleMap.toString());
//      Map<String,int> intMap = await CleverTapPlugin.getMapOfIntegerVariable("integerMapVar", null);
//      print("Map of int = "+boolMap.toString());
//      Map<String,String> strMap = await CleverTapPlugin.getMapOfStringVariable("stringMapVar", null);
//      print("Map of string = "+strMap.toString());
    });
  }

  void onDisplayUnitsLoaded(List<dynamic> displayUnits){
    this.setState(() async {
      List displayUnits = await CleverTapPlugin.getAllDisplayUnits();
      print("Display Units = "+ displayUnits.toString());
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: SingleChildScrollView(
            padding: const EdgeInsets.all(8.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                  onPressed: () => CleverTapPlugin.setDebugLevel(3),
                  child: Text('Debug Level'),
                ),
                RaisedButton(
                    onPressed: () => recordEvent(),
                    child: Text('Push Event')
                ),
                RaisedButton(
                    onPressed: () => recordUser(),
                    child: Text('Push User')
                ),
                RaisedButton(
                    onPressed: () => recordChargedEvent(),
                    child: Text('Charged Event')
                ),
                RaisedButton(
                    onPressed: () => showInbox(),
                    child: Text('Show Inbox')
                ),
                RaisedButton(
                    onPressed: () => setOptOut(),
                    child: Text('Opt In/Out')
                ),
                RaisedButton(
                    onPressed: () => setOffline(),
                    child: Text('On/Off-line')
                ),
                RaisedButton(
                    onPressed: () => setEnableDeviceNetworkingInfo(),
                    child: Text('Enable/Disable Networking Info')
                ),
                RaisedButton(
                    onPressed: () => enablePersonalization(),
                    child: Text('Enable Personalization')
                ),
                RaisedButton(
                    onPressed: () => disablePersonalization(),
                    child: Text('Disable Personalization')
                ),
                RaisedButton(
                    onPressed: () => eventGetFirstTime(),
                    child: Text('Get Event First Time')
                ),
                RaisedButton(
                    onPressed: () => eventGetOccurrences(),
                    child: Text('Get Event Occurrences')
                ),
                RaisedButton(
                    onPressed: () => getEventDetail(),
                    child: Text('Get Event Detail')
                ),
                RaisedButton(
                    onPressed: () => getEventHistory(),
                    child: Text('Get Event History')
                ),
                RaisedButton(
                    onPressed: () => setLocation(),
                    child: Text('Set Location')
                ),
                RaisedButton(
                    onPressed: () => getCTAttributionId(),
                    child: Text('Get Attribution ID')
                ),
                RaisedButton(
                    onPressed: () => getCleverTapId(),
                    child: Text('Get CleverTap ID')
                ),
                RaisedButton(
                    onPressed: () => onUserLogin(),
                    child: Text('On User Login')
                ),
                RaisedButton(
                    onPressed: () => eventGetLastTime(),
                    child: Text('Get Event Last Time ')
                ),
                RaisedButton(
                    onPressed: () => removeProfileValue(),
                    child: Text('Remove Profile Value For Key')
                ),
                RaisedButton(
                    onPressed: () => setProfileMultiValue(),
                    child: Text('Set Profile Multi Values')
                ),
                RaisedButton(
                    onPressed: () => addMultiValue(),
                    child: Text('Add Profile Multi Value')
                ),
                RaisedButton(
                    onPressed: () => addMultiValues(),
                    child: Text('Add Profile Multi values')
                ),
                RaisedButton(
                    onPressed: () => removeMultiValue(),
                    child: Text('Remove Multi Value')
                ),
                RaisedButton(
                    onPressed: () => removeMultiValues(),
                    child: Text('Remove Multi Values')
                ),
                RaisedButton(
                    onPressed: () => getTimeElapsed(),
                    child: Text('Session Time Elapsed')
                ),
                RaisedButton(
                    onPressed: () => getTotalVisits(),
                    child: Text('Session Total Visits')
                ),
                RaisedButton(
                    onPressed: () => getScreenCount(),
                    child: Text('Session Screen Count')
                ),
                RaisedButton(
                    onPressed: () => getPreviousVisitTime(),
                    child: Text('Session Previous Visit Time')
                ),
                RaisedButton(
                    onPressed: () => getUTMDetails(),
                    child: Text('Session Get UTM Details')
                ),
                RaisedButton(
                    onPressed: () => registerBooleanVar(),
                    child: Text('Register Boolean Variable')
                ),
                RaisedButton(
                    onPressed: () => registerDoubleVar(),
                    child: Text('Register Double Variable')
                ),
                RaisedButton(
                    onPressed: () => registerIntegerVar(),
                    child: Text('Register Integer Variable')
                ),
                RaisedButton(
                    onPressed: () => registerStringVar(),
                    child: Text('Register String Variable')
                ),
                RaisedButton(
                    onPressed: () => registerBooleanListVar(),
                    child: Text('Register Boolean List Variable')
                ),
                RaisedButton(
                    onPressed: () => registerDoubleListVar(),
                    child: Text('Register Double List Variable')
                ),
                RaisedButton(
                    onPressed: () => registerIntegerListVar(),
                    child: Text('Register Integer List Variable')
                ),
                RaisedButton(
                    onPressed: () => registerStringListVar(),
                    child: Text('Register String List Variable')
                ),
                RaisedButton(
                    onPressed: () => registerBooleanMapVar(),
                    child: Text('Register Boolean Map Variable')
                ),
                RaisedButton(
                    onPressed: () => registerDoubleMapVar(),
                    child: Text('Register Double Map Variable')
                ),
                RaisedButton(
                    onPressed: () => registerIntegerMapVar(),
                    child: Text('Register Integer Map Variable')
                ),
                RaisedButton(
                    onPressed: () => registerStringMapVar(),
                    child: Text('Register String Map Variable')
                ),
                RaisedButton(
                    onPressed: () => getVariables(),
                    child: Text('Get Variable')
                ),
                RaisedButton(
                    onPressed: () => getAdUnits(),
                    child: Text('Get Ad Units')
                ),
                RaisedButton(
                    onPressed: () => getAllInboxMessages(),
                    child: Text('Get All Inbox Messages')
                ),
                RaisedButton(
                    onPressed: () => getUnreadInboxMessages(),
                    child: Text('Get Unread Inbox Messages')
                ),
                RaisedButton(
                    onPressed: () => getInboxMessageForId(),
                    child: Text('Get Inbox Message For ID')
                ),
                RaisedButton(
                    onPressed: () => deleteInboxMessageForId(),
                    child: Text('Delete Inbox Message For ID')
                ),
                RaisedButton(
                    onPressed: () => markReadInboxMessageForId(),
                    child: Text('Mark Inbox Message As Read')
                ),
                RaisedButton(
                    onPressed: () => pushInboxNotificationClickedEventForId(),
                    child: Text('pushInboxNotificationClickedEventForId')
                ),
                RaisedButton(
                    onPressed: () => pushInboxNotificationViewedEventForId(),
                    child: Text('pushInboxNotificationViewedEventForId')
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> recordEvent(){
    var eventData = {
      // Key:    Value
      'first': 'partridge',
      'second': 'turtledoves'
    };
    CleverTapPlugin.recordEvent("Flutter Event",eventData);
  }

  void recordChargedEvent(){
    var item1 = {
      // Key:    Value
      'name': 'thing1',
      'amount': '100'
    };
    var item2 = {
      // Key:    Value
      'name': 'thing2',
      'amount': '100'
    };
    var items = [item1,item2];
    var chargeDetails = {
      // Key:    Value
      'total': '200',
      'payment': 'cash'
    };
    CleverTapPlugin.recordChargedEvent(chargeDetails, items);
  }

  void recordUser(){
    var stuff = ["bags","shoes"];
    var profile = {
      'Name': 'Thor',
      'Identity': '100',
      'DOB': '22-04-2000',///Key always has to be "DOB" and format should always be dd-MM-yyyy
      'Email': 'thor1@asgard.com',
      'Phone': '14155551234',
      'props': 'property1',
      'stuff': stuff
    };
    CleverTapPlugin.profileSet(profile);
  }

  void showInbox(){
    if(inboxInitialized) {
      CleverTapPlugin.showInbox(null);
    }
  }

 void getAllInboxMessages() async{
    List messages = await CleverTapPlugin.getAllInboxMessages();
    print("Inbox Messages = "+ messages.toString());
    
  }

  void getUnreadInboxMessages() async{

    List messages = await CleverTapPlugin.getUnreadInboxMessages();
    print("Unread Inbox Messages = "+ messages.toString());
  }

  void getInboxMessageForId() async{
    var messageId=await getFirstInboxMessageId();

    if(messageId==null) {
      setState((() {
        print("Inbox Message id is null");
      }));
      return;
    }

    var messageForId= await CleverTapPlugin.getInboxMessageForId(messageId);
    setState((() {
      print("Inbox Message for id =  ${messageForId.toString()}");
    }));

  }

  void deleteInboxMessageForId() async{
    var messageId=await getFirstInboxMessageId();

    if(messageId==null) {
      setState((() {
        print("Inbox Message id is null");
      }));
      return;
    }

    await CleverTapPlugin.deleteInboxMessageForId(messageId);

    setState((() {
      print("Deleted Inbox Message with id =  ${messageId}");
    }));

  }

  void markReadInboxMessageForId() async{
    var messageList = await CleverTapPlugin.getUnreadInboxMessages();

    if (messageList == null || messageList.length==0) return;
    Map<dynamic, dynamic> itemFirst = messageList[0];

    if(Platform.isAndroid) {
      await CleverTapPlugin.markReadInboxMessageForId(itemFirst["id"]);
      setState((() {
        print("Marked Inbox Message as read with id =  ${itemFirst["id"]}");
      }));
    }else if(Platform.isIOS){
      await CleverTapPlugin.markReadInboxMessageForId(itemFirst["_id"]);
      setState((() {
        print("Marked Inbox Message as read with id =  ${itemFirst["_id"]}");
      }));
    }



  }

  void pushInboxNotificationClickedEventForId() async{
    var messageId=await getFirstInboxMessageId();

    if(messageId==null) {
      setState((() {
        print("Inbox Message id is null");
      }));
      return;
    }

    await CleverTapPlugin.pushInboxNotificationClickedEventForId(messageId);

    setState((() {
      print("Pushed NotificationClickedEvent for Inbox Message with id =  ${messageId}");
    }));

  }

  void pushInboxNotificationViewedEventForId() async{
    var messageId=await getFirstInboxMessageId();

    if(messageId==null) {
      setState((() {
        print("Inbox Message id is null");
      }));
      return;
    }

    await CleverTapPlugin.pushInboxNotificationViewedEventForId(messageId);

    setState((() {
      print("Pushed NotificationViewedEvent for Inbox Message with id =  ${messageId}");
    }));

  }

  Future<String> getFirstInboxMessageId() async{

    var messageList = await CleverTapPlugin.getAllInboxMessages();
    print("inside getFirstInboxMessageId");
    if (messageList == null || messageList.length==0) return null;
    Map<dynamic, dynamic> itemFirst = messageList[0];
    print(itemFirst.toString());

    if(Platform.isAndroid) {
      return itemFirst["id"];
    }else if (Platform.isIOS){
      return itemFirst["_id"];
    }
  }

  void setOptOut(){
    if(optOut){
      CleverTapPlugin.setOptOut(false);
      optOut = false;
    }else{
      CleverTapPlugin.setOptOut(true);
      optOut = true;
    }
  }

  void setOffline(){
    if(offLine){
      CleverTapPlugin.setOffline(false);
      offLine = false;
    }else{
      CleverTapPlugin.setOffline(true);
      offLine = true;
    }
  }

  void setEnableDeviceNetworkingInfo(){
    if(enableDeviceNetworkingInfo){
      CleverTapPlugin.enableDeviceNetworkInfoReporting(false);
      enableDeviceNetworkingInfo = false;
    }else{
      CleverTapPlugin.enableDeviceNetworkInfoReporting(true);
      enableDeviceNetworkingInfo = true;
    }
  }

  void recordScreenView(){
    var screenName = "Home Screen";
    CleverTapPlugin.recordScreenView(screenName);
  }

  void eventGetFirstTime(){
    var eventName = "Flutter Event";
    CleverTapPlugin.eventGetFirstTime(eventName).then((eventFirstTime) {
      if (eventFirstTime == null) return;
      setState((() {
        print("Event First time CleverTap = "+ eventFirstTime.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void eventGetLastTime(){
    var eventName = "Flutter Event";
    CleverTapPlugin.eventGetLastTime(eventName).then((eventLastTime) {
      if (eventLastTime == null) return;
      setState((() {
        print("Event Last time CleverTap = "+ eventLastTime.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void eventGetOccurrences(){
    var eventName = "Flutter Event";
    CleverTapPlugin.eventGetOccurrences(eventName).then((eventOccurrences) {
      if (eventOccurrences == null) return;
      setState((() {
        print("Event detail from CleverTap = "+ eventOccurrences.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getEventDetail(){
    var eventName = "Flutter Event";
    CleverTapPlugin.eventGetDetail(eventName).then((eventDetailMap) {
      if (eventDetailMap == null) return;
      setState((() {
        print("Event detail from CleverTap = "+ eventDetailMap.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getEventHistory(){
    var eventName = "Flutter Event";
    CleverTapPlugin.getEventHistory(eventName).then((eventDetailMap) {
      if (eventDetailMap == null) return;
      setState((() {
        print("Event History from CleverTap = "+ eventDetailMap.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void setLocation(){
    var lat = 19.07;
    var long = 72.87;
    CleverTapPlugin.setLocation(lat,long);
  }

  void getCTAttributionId(){
    CleverTapPlugin.profileGetCleverTapAttributionIdentifier().then((attributionId) {
      if (attributionId == null) return;
      setState((() {
        print("Attribution Id = "+ "$attributionId");
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getCleverTapId() {
    CleverTapPlugin.profileGetCleverTapID().then((clevertapId) {
      if (clevertapId == null) return;
      setState((() {
        print("$clevertapId");
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void onUserLogin(){
    var stuff = ["bags","shoes"];
    var profile = {
      'Name': 'Captain America',
      'Identity': '100',
      'Email': 'captain@america.com',
      'Phone': '+14155551234',
      'stuff' : stuff
    };
    CleverTapPlugin.onUserLogin(profile);
  }

  void removeProfileValue(){
    CleverTapPlugin.profileRemoveValueForKey("props");
  }

  void setProfileMultiValue(){
    var values = ["value1","value2"];
    CleverTapPlugin.profileSetMultiValues("props", values);
  }

  void addMultiValue(){
    var value = "value1";
    CleverTapPlugin.profileAddMultiValue("props", value);
  }

  void addMultiValues(){
    var values = ["value1","value2"];
    CleverTapPlugin.profileAddMultiValues("props", values);
  }

  void removeMultiValue(){
    var value = "value1";
    CleverTapPlugin.profileRemoveMultiValue("props", value);
  }

  void removeMultiValues(){
    var values = ["value1","value2"];
    CleverTapPlugin.profileRemoveMultiValues("props", values);
  }

  void getTimeElapsed(){
    CleverTapPlugin.sessionGetTimeElapsed().then((timeElapsed) {
      if (timeElapsed == null) return;
      setState((() {
        print("Session Time Elapsed = "+ timeElapsed.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getTotalVisits(){
    CleverTapPlugin.sessionGetTotalVisits().then((totalVisits) {
      if (totalVisits == null) return;
      setState((() {
        print("Session Total Visits = "+ totalVisits.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getScreenCount(){
    CleverTapPlugin.sessionGetScreenCount().then((screenCount) {
      if (screenCount == null) return;
      setState((() {
        print("Session Screen Count = "+ screenCount.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getPreviousVisitTime(){
    CleverTapPlugin.sessionGetPreviousVisitTime().then((previousTime) {
      if (previousTime == null) return;
      setState((() {
        print("Session Previous Visit Time = "+ previousTime.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void getUTMDetails(){
    CleverTapPlugin.sessionGetUTMDetails().then((utmDetails) {
      if (utmDetails == null) return;
      setState((() {
        print("Session UTM Details = "+ utmDetails.toString());
      }));
    }).catchError((error) {
      setState(() {
        print("$error");
      });
    });
  }

  void enablePersonalization(){
    CleverTapPlugin.enablePersonalization();
    print("Personalization enabled");
  }

  void disablePersonalization(){
    CleverTapPlugin.disablePersonalization();
    print("Personalization disabled");
  }

  void registerBooleanVar(){
    CleverTapPlugin.registerBooleanVariable("boolVar");
    print("boolVar variable registered");
  }

  void registerDoubleVar(){
    CleverTapPlugin.registerDoubleVariable("doubleVar");
    print("doubleVar variable registered");
  }

  void registerIntegerVar(){
    CleverTapPlugin.registerIntegerVariable("integerVar");
    print("integerVar variable registered");
  }

  void registerStringVar(){
    CleverTapPlugin.registerStringVariable("stringVar");
    print("stringVar variable registered");
  }

  void registerBooleanListVar() {
    CleverTapPlugin.registerListOfBooleanVariable("boolListVar");
    print("boolListVar variable registered");
  }

  void registerDoubleListVar() {
    CleverTapPlugin.registerListOfDoubleVariable("doubleListVar");
    print("doubleListvar variable registered");
  }

  void registerIntegerListVar() {
    CleverTapPlugin.registerListOfIntegerVariable("integerListVar");
    print("integerListVar variable registered");
  }

  void registerStringListVar() {
    CleverTapPlugin.registerListOfStringVariable("stringListVar");
    print("stringListVar variable registered");
  }

  void registerBooleanMapVar() {
    CleverTapPlugin.registerMapOfBooleanVariable("boolMapVar");
    print("boolMapVar variable registered");
  }

  void registerDoubleMapVar() {
    CleverTapPlugin.registerMapOfDoubleVariable("doubleMapVar");
    print("doubleMapVar variable registered");
  }

  void registerIntegerMapVar() {
    CleverTapPlugin.registerMapOfIntegerVariable("integerMapVar");
    print("integerListVar variable registered");
  }

  void registerStringMapVar() {
    CleverTapPlugin.registerMapOfStringVariable("stringMapVar");
    print("stringListVar variable registered");
  }

  void getVariables() async {
    bool booleanVar = await CleverTapPlugin.getBooleanVariable("boolVar", false);
    print("Boolean var = " + booleanVar.toString());
    double doubleVar = await CleverTapPlugin.getDoubleVariable("doubleVar", 9.99);
    print("Double var = " + doubleVar.toString());
    int integerVar = await CleverTapPlugin.getIntegerVariable("integerVar", 999);
    print("Integer var = "+integerVar.toString());
    String stringVar = await CleverTapPlugin.getStringVariable("stringVar", "defaultString");
    print("String var = "+stringVar.toString());
    List<dynamic> boolList = await CleverTapPlugin.getListOfBooleanVariable("boolListVar", null);
    print("List of bool = "+boolList.toString());
    List<dynamic> doubleList = await CleverTapPlugin.getListOfDoubleVariable("doubleListVar", null);
    print("List of double = "+doubleList.toString());
    List<dynamic> intList = await CleverTapPlugin.getListOfIntegerVariable("integerListVar", null);
    print("Integer List = "+intList.toString());
    List<dynamic> stringList = await CleverTapPlugin.getListOfStringVariable("stringListVar", null);
    print("String List = "+stringList.toString());
    Map<String,bool> boolMap = await CleverTapPlugin.getMapOfBooleanVariable("boolMapVar", null);
    print("Map of bool = "+boolMap.toString());
    Map<String,double> doubleMap = await CleverTapPlugin.getMapOfDoubleVariable("doubleMapVar", null);
    print("Map of double = "+doubleMap.toString());
    Map<String,int> intMap = await CleverTapPlugin.getMapOfIntegerVariable("integerMapVar", null);
    print("Map of int = "+boolMap.toString());
    Map<String,String> strMap = await CleverTapPlugin.getMapOfStringVariable("stringMapVar", null);
    print("Map of string = "+strMap.toString());
  }

  void getAdUnits() async{
    List displayUnits = await CleverTapPlugin.getAllDisplayUnits();
    print("Display Units = "+ displayUnits.toString());
  }  

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  clevertap_plugin: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:clevertap_plugin/clevertap_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/clevertap_plugin.dart.

Run flutter format to format lib/clevertap_plugin.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test