Skip to main content
The onclarity plugin is a thin Dart layer over the Android and iOS SDKs. The chat opens as a native container over your Flutter UI, so nothing is added to your widget tree and your routes are untouched while it is open. Requirements: Flutter 3.44 or later, Android API 21 or later, iOS 15 or later.

Get your credentials

A Flutter app ships as two native apps, and Clarity matches a channel per platform, so you need two integration keys. In the cabinet, go to Settings > Mobile SDK, click Add Integration and choose Flutter. Enter both App IDs: You get one Organization Id and two integration keys, one per platform. The live chat host is https://live-chat.leap.onclarity.com. These values are identifiers, not secrets, so shipping them in the app is fine.

Install

Android needs nothing more: the native SDK comes from Maven Central.

iOS: raise the deployment target

The iOS SDK needs iOS 15, and Flutter’s app template targets iOS 13, so pod install fails until you raise it. Change it in both places:
and in Xcode, Runner > General > Minimum Deployments > iOS 15.0. Then run pod install in ios/.

Android: Kotlin version

The plugin needs Kotlin 2.0 or later in your Android project. Flutter 3.44’s template already has it. An older project fails with compiled with an incompatible version of Kotlin; raise the version in android/settings.gradle:
The Android build prints a warning that onclarity applies the Kotlin Gradle Plugin. It is harmless, and you have nothing to change.

Initialize

Pass both keys once. The plugin picks the right one for the platform it runs on.

Configuration options

Identify the user

ClarityUser also takes lastName, phone and avatar. Changing externalId is an account switch and starts a separate conversation; changing other fields on the same id updates the profile. On logout:
The Flutter plugin does not support signed identity (jwt) yet. Identity passed here is not verified, so do not turn on Require a verified identity for the channels your Flutter app uses. The userHash field is deprecated and not verified; do not rely on it.

Open the chat

The chat appears only once it is ready. A failure arrives on the event stream instead of a blank sheet.

Listen for events

Everything the native SDKs report arrives on one broadcast stream. ClarityEvent is a sealed class, so a switch over it is exhaustive:
When the app returns to the foreground, call await Clarity.refresh() to pull anything missed.
The plugin owns the native listener and fans it out to Clarity.events. Do not register your own native listener on either platform.

Attributes and product events

An unsupported value type throws ArgumentError at your call site.
If your workspace marks contact attributes as required, set them right after Clarity.init, before the chat first loads. A session missing a required attribute is refused, and show() reports ClarityErrorKind.pageLoadFailed naming the missing keys. Alternatively pass autoPreload: false and call Clarity.preload() once the attributes are set.

Push notifications

Clarity’s push routing is FCM-based. With firebase_messaging in your app, forward the token and messages from Dart:
On iOS, a tap on a Clarity notification reopens the chat only if your AppDelegate forwards it, which Dart cannot do. Add this to ios/Runner/AppDelegate.swift:
Android needs nothing more; the SDK handles its own notification taps. On Android 13 and later, request POST_NOTIFICATIONS yourself. The SDK never prompts.
Background push delivery is enabled per organization. Ask your Clarity contact about availability.

Huawei and AppGallery builds

If your Android channel was created with My mobile is Huawei, tell the plugin in ClarityConfig:
Set it from your build flavour, not by probing the device. Chat works on devices without Google services; push does not, because push is FCM-only.

Attachments, voice and dictation

  • Camera on iOS: add NSCameraUsageDescription to ios/Runner/Info.plist to enable Take Photo. Photo library and file uploads work without it.
  • Voice calling and dictation: declare microphone access, RECORD_AUDIO in the Android manifest and NSMicrophoneUsageDescription in the iOS Info.plist. Without it, the chat shows no microphone button.

Customization

The chat’s colours, logos, font and texts come from Settings > Widget in the cabinet, the same settings as the web widget. In code you control the presentation, language and autoFocusInput.

API reference

Troubleshooting

Listen to Clarity.events for ClarityErrorEvent. handshakeRejected means a wrong organization id, integration key or App ID (each channel’s App ID must equal that platform’s identifier), or a Huawei platform mismatch. network means the device cannot reach baseUrl.
Raise the iOS deployment target to 15.0 in ios/Podfile and in Xcode, as in Install.
Raise your project’s Kotlin Gradle plugin to 2.0 or later, as in Install.
Add NSCameraUsageDescription to ios/Runner/Info.plist.