# Flutter

A wrapper for the MOVE SDK is available for Google's Flutter framework and published on pub.dev.

<https://pub.dev/packages/movesdk>

## Installation

Add the Dolphin MOVE SDK package to your flutter app using:

```sh
flutter pub add movesdk
```

or, by adding it as a dependency to your *pubspec.yaml* file and run:

```bash
flutter pub get
```

{% hint style="warning" %}
Add the following section within the **root build.gradle**.

```
allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://dolphin.jfrog.io/artifactory/move-sdk-libs-release"
        }
    }
}
```

{% endhint %}

{% hint style="warning" %}
Also please check if the following values are set within the **app build.gradle**.

\
`minSdkVersion 26 or higher`\
`compileSdkVersion 34`\
`targetSdkVersion 34`

<pre><code><strong>android {
</strong>    compileSdkVersion 34
    // ...
    // ...
    defaultConfig {
        // ...
        // ...
        minSdkVersion 26
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // ...
        // ...
    }
    // ...
    // ...
}
</code></pre>

{% endhint %}

See [Flutter - Using packages](https://docs.flutter.dev/packages-and-plugins/using-packages) for further information regarding package use.

Import the package in your code:

```dart
import 'package:movesdk/movesdk.dart';
```

See the included example ([move-sdk-flutter/example](https://pub.dev/packages/movesdk/example)) project in the package for reference on how to get started.

## iOS

### Initialization

The SDK will be automatically initialized and load its persisted state in the plugin's lifecycle through the`FlutterAppDelegate`.&#x20;

### Setting up Permissions

The MOVE SDK requires several permissions to function.

Make sure required [permissions](https://docs.movesdk.com/move-platform/sdk/appendix/ios/permission-handling) are added in your iOS Runner.workspace and also the corresponding strings for requesting user permissions are set in the projects *Info.plist*.

![Location updates background mode capability](https://394612935-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXD5xlIFUYU8eK_kkLo%2F-Ma7-Qp0tvRtlszHh2aC%2F-MaWrFoEnyiReo8XoJL3%2Fimage.png?alt=media\&token=171c219f-f0e1-4d9a-9fe8-a0ccb47078a6)

If you are using the [**flutter-permission-handler**](https://github.com/Baseflow/flutter-permission-handler) package refer to [this guide](https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler/README.md) (see also [here](https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler/example/ios/Podfile)) to add the permissions in your iOS *Podspec* file.

## Android

### Initialization

The SDK needs to be initialized at the start of the app by calling *MoveSdk.init.* It is recommended to put this in the Application's `onCreate` method. This will load the persistent Move SDK state.

```kotlin
import io.dolphin.move.MoveSdk

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        val sdk = MoveSdk.init(this)
        ...
    }
    
    ...
}
```

### Setting up Permissions

Permission setup is inherited automatically.
