SDK Installation

Flutter is Google’s UI toolkit for building natively compiled applications for iOS and Android from a single codebase.

Download

Installation

To add MoEngage's Flutter SDK to your application, edit your pubspec.yaml to add moengage_flutter as a dependency.

pubspec.yaml
dependencies:
	moengage_flutter: $lastestVersion

$latestVersion refers to the latest version of the plugin.

Post including the dependency run flutter pub get command in terminal to install the dependency.

Android SDK Installation

Add mavenCentral() repository in the project-level build.gradle file.

build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Once you install the Flutter Plugin add MoEngage's native Android SDK dependency to the Android project of your application along with the dependencies mentioned below.
Navigate to android --> app --> build.gradle. Add the MoEngage Android SDK's dependency inside the dependencies block.

build.gradle
  dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation("androidx.core:core:1.3.1")
    implementation("androidx.appcompat:appcompat:1.2.0")
    implementation("androidx.lifecycle:lifecycle-process:2.2.0")
    implementation("com.moengage:moe-android-sdk:11.6.01")
}

iOS SDK Installation

We have added our native SDK MoEngage-iOS-SDK as a dependency for moengage_flutter plugin, hence run flutter build ios command once to generate the Pod file for your iOS project and run pod install inside your project's ios directory to add the plugin and native SDK to your iOS Project.

Web SDK Installation

To add the MoEngage Flutter Web SDK to your application, edit your application's pubspec.yaml file and add the below dependency to it:

pubspec.yaml
dependencies:
 moengage_flutter_web: $latestSdkVersion

replace $latestSdkVersion with the latest SDK version.

Run flutter packages get to install the SDK.

Initialise Plugin

In the project's App Widget call initialise() of MoEngageFlutter plugin in initState() method as shown below:

Dart
  import 'package:moengage_flutter/moengage_flutter.dart';

  final MoEngageFlutter _moengagePlugin = MoEngageFlutter();

  @override
  void initState() {
    super.initState();
    initPlatformState();
    _moengagePlugin.initialise();
  }

For more information, refer to Flutter SDK.

Was this article helpful?
0 out of 0 found this helpful