# Flutter

[*Flutter*](https://flutter.dev/) stands as an innovative open-source UI software development kit, thoughtfully crafted by Google. With Flutter, you have the ability to create applications that span across diverse platforms, such as Android, iOS, Linux, Mac, Windows, Google Fuchsia, and the web, all while working from a single, cohesive codebase.&#x20;

Our Antsomi Flutter Mobile SDK is expertly designed to seamlessly harmonize with the latest iterations of both Android and iOS, offering you a powerful solution for building engaging cross-platform applications.

Here's how you can integrate the Antsomi SDK with your Flutter apps:

## 1. Installation

**Step 1:** Add the `antsomisdk` plugin in your `pubspec.yaml` file.

{% tabs %}
{% tab title="Dart" %}
{% code title="pubspec.yaml" %}

```yaml
dependencies:
  antsomisdk: 0.0.51
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Antsomi SDK only supports Dart SDK 3.0 and above.
{% endhint %}

**Step 2:** Run `flutter packages get` to install the SDK.

## 2. Antsomi Instance Initialization

**Step 1:** Initialize Antsomi in `main.dart` in `main()`.

{% tabs %}
{% tab title="Dart" %}

<pre class="language-dart" data-title="main.dart"><code class="lang-dart"><strong>import 'package:antsomisdk/antsomi.dart';
</strong>
void main() {
  antsomiSdk = Antsomi();
}
</code></pre>

{% endtab %}
{% endtabs %}

**Step 2:** Provide the Antsomi instance with your portal config.

{% tabs %}
{% tab title="Dart" %}
{% code title="main.dart" %}

```dart
antsomiSdk.config(
  appGroupId: 'group.antsomi.mstore',
  portalId: '564890637',
  propsId: '564993464',
  applicationID: 'e4e8d06e-4d97-43df-93e8-c36238147ca0',
);

// if you use app push of Antsomi
antsomiSdk.instance.requestNotificationPermission();
```

{% endcode %}
{% endtab %}
{% endtabs %}

In which:

<table><thead><tr><th width="187">Key</th><th>Description</th></tr></thead><tbody><tr><td>appGroupId</td><td><p>Your iOS App Group ID. </p><p>For example, <code>group.antsomi.mstore</code></p></td></tr><tr><td>portalId</td><td>Your CDP365 Portal ID.<br>For example, <code>564890637</code></td></tr><tr><td>propsId</td><td>Your CDP365 Event Source ID.<br>For example, <code>564993464</code></td></tr><tr><td>applicationID</td><td>Your CDP365 Application ID.<br>For example, <code>e4e8d06e-4d97-43df-93e8-c36238147ca0</code></td></tr></tbody></table>

{% hint style="info" %}
If you haven't had your CDP365 Application ID, please follow this [instruction](https://docs.antsomi.com/cdp-365-user-guide-en/marketing-hub/destinations/all-destinations/app-notification#1.-antsomi-app-notification).
{% endhint %}

Remember to verify the user's mobile device operating system to ensure accurate event source configuration. In CDP365, mobile app event sources are categorized into iOS and Android sources, so it's essential to distinguish between them based on the user's device OS.

Finally, your setting will be similar to the code snippet below:

{% tabs %}
{% tab title="Drat" %}
{% code title="main.dart" %}

```dart
import 'dart:io' show Platform;
import 'package:antsomisdk/antsomi.dart';

void main() {
  antsomiSdk = Antsomi();
  
  if (Platform.isAndroid) {
    antsomiSdk .config(
        appGroupId: 'group.antsomi.mstore',
        portalId: '564890637',
        propsId: '564993464',
        applicationID: 'e4e8d06e-4d97-43df-93e8-c36238147ca0',
    );
  } else {
    antsomiSdk.config(
        appGroupId: 'group.antsomi.mstore',
        portalId: '564890637',
        propsId: '564993465',
        applicationID: 'e4e8d06e-4d97-43df-93e8-c36238147ca0',
    );
  }
  
  // if you use app push of Antsomi
    antsomiSdk.instance.requestNotificationPermission();
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

**NEXT STEP**

* [Tracking User Attributes](/developers-guide/hybrid-apps/flutter/tracking-users.md)
* [Tracking User Events](/developers-guide/hybrid-apps/flutter/tracking-events.md)
* [Configure Push Messaging](/developers-guide/hybrid-apps/flutter/push-messaging.md)
* [Configure App Inbox Messaging](/developers-guide/hybrid-apps/flutter/app-inbox-messaging.md)
* [Implementing App In-line Content](/developers-guide/hybrid-apps/flutter/app-in-line-content.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.antsomi.com/developers-guide/hybrid-apps/flutter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
