> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smartcomply.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Flutter SDK

> Integrate Adhere identity verification and liveness detection into your Flutter app.

# Adhere Flutter SDK

A powerful Flutter package for Adhere identity verification and facial liveness detection. Our SDK delivers a drop-in UI that seamlessly orchestrates BVN/NIN verification (Nigeria), Document parsing (International), and video-based ML Kit facial liveness challenges.

## Features

* **Drop-in UI Integration** — `sdk.open(context)` launches our polished UI module natively on top of your app.
* **Dynamic Client Configuration** — Fetches available document types securely from your Adhere Dashboard rules.
* **One-Time Use Policy System** — Verifications are securely bound utilizing a single-use parameter.
* **Identity Onboarding** — Verifies BVN & NIN directly via national APIs, or scans Passports & National ID Cards.
* **Liveness Detection** — Animated face action challenges (Blinking, Turning Head) backed by Google ML Kit.

## Installation

In your app's `pubspec.yaml`:

```yaml theme={null}
dependencies:
  smartcomply_sdk: ^0.1.0
```

Then run `flutter pub get`.

## Platform Setup

### Android

In `android/app/src/main/AndroidManifest.xml`, ensure your app has permission to access the camera:

```xml theme={null}
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
```

Set the minimum SDK version in `android/app/build.gradle`:

```groovy theme={null}
android {
    defaultConfig {
        minSdk 21
    }
}
```

### iOS

In `ios/Runner/Info.plist`, declare the camera usage description:

```xml theme={null}
<key>NSCameraUsageDescription</key>
<string>Camera is needed for liveness verification.</string>
```

***

## Quick Start (Recommended)

The simplest way to integrate our SDK is to use the full wrapper widget. Upon launching, the SDK will automatically prompt the user for their **Client ID**.

```dart theme={null}
import 'package:smartcomply_sdk/smartcomply_sdk.dart';

// 1. Create the SDK instance using your secret API Key
final sdk = SmartComply(
  const SDKConfig(
    apiKey: 'your_live_api_key',
    environment: Environment.production, // Use Environment.sandbox for testing
  )
);

// 2. Wrap the execution in an asynchronous callback
void startVerification(BuildContext context) async {
  try {
    // Open the Adhere UI
    final result = await sdk.open(context);

    if (result.success) {
      print('Verification passed! Live Session Token: ${result.sessionToken}');
    } else {
      print('Failed or Canceled: ${result.errorMessage}');
    }
  } catch (e) {
    print("Fatal App Error processing SDK: $e");
  }
}
```

The SDK handles everything automatically:

1. Shows an initial Client ID input screen.
2. Identifies the user's origin and prompts for ID types (BVN, NIN, Passport, etc).
3. Requests camera permissions.
4. Guides the user through liveness face capturing.
5. Securely revokes the session to enforce single-use policy.

***

## Advanced Usage (Headless Architecture)

If you are building your own UI from scratch instead of using our wrapper, you must capture the `Client ID` manually and trigger the endpoints yourself:

```dart theme={null}
// 1. Manually initialize the session using a dynamic input UUID
final session = await sdk.createSession("user_provided_client_id");

// 2. Verify identity directly via backend API
final identity = await sdk.onboarding.verify(
  onboardingType: OnboardingType.bvn,
  idNumber: '22012345678',
);

// 3. Mount the Camera UI Liveness Checker Widget directly in your app tree
if (identity.isVerified) {
  final liveness = await sdk.liveness.startCheck(
    context,
    identifier: '22012345678',
    identifierType: 'bvn',
    country: 'nigeria',
    challengeActions: [ChallengeAction.blink, ChallengeAction.turnLeft],
  );
  print('Liveness: ${liveness.status}');
}
```

## Supported Liveness Actions

Our engine can dynamically challenge users based on your Dashboard rules:

| Action     | Enum Value                  | Detection Method                     |
| ---------- | --------------------------- | ------------------------------------ |
| Blink      | `ChallengeAction.blink`     | ML Kit eye open probability tracking |
| Turn left  | `ChallengeAction.turnLeft`  | ML Kit `headEulerAngleY` analysis    |
| Turn right | `ChallengeAction.turnRight` | ML Kit `headEulerAngleY` analysis    |
| Turn head  | `ChallengeAction.turnHead`  | ML Kit `headEulerAngleY` analysis    |
| Open mouth | `ChallengeAction.openMouth` | ML Kit classification                |
