# Flutter

## Overview

The `vove_id_flutter` plugin wraps the native Vove iOS and Android SDKs to deliver a single, idiomatic Dart API for ID verification, KYC, and AML compliance. It supports:

* Sandbox and production environments
* Full-screen or custom UI flows
* Locale overrides
* Vocal guidance
* Per-step exits and next-step routing
* Max-attempt callbacks

## Quickstart

{% stepper %}
{% step %}

### Install the plugin

Add the dependency to your `pubspec.yaml`:

```yaml
dependencies:
  vove_id_flutter: ^1.6.0
```

Then run `flutter pub get`.
{% endstep %}

{% step %}

### Initialize the SDK

Call `Vove.initialize` as soon as your verification UI loads—before you invoke `Vove.start`—to ensure the native SDK is ready. For most apps this happens when the screen that initiates verification is displayed:

```dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Vove.initialize(
    environment: VoveEnvironment.sandbox, // or production
    publicKey: 'YOUR_PUBLIC_KEY',
  );
  runApp(const MyApp());
}
```

{% endstep %}

{% step %}

### Start a verification session

Generate a session token on your backend (see Vove’s REST API docs) and pass it to `Vove.start`. The call returns a `VoveVerificationResult` describing the current status and the next required step (when `exitAfterEachStep` is enabled).

```dart
final config = VoveStartConfiguration(
  showUI: true,
  exitAfterEachStep: false,
  onMaxAttemptsReached: () {
    // e.g., prompt the user to contact support
  },
);

final result = await Vove.start(
  sessionToken: 'SESSION_TOKEN_FROM_BACKEND',
  configuration: config,
  locale: VoveLocale.fr,
  enableVocalGuidance: true,
);

switch (result.status) {
  case VoveVerificationStatus.success:
    // grant access
    break;
  case VoveVerificationStatus.pending:
    // wait for manual review
    break;
  case VoveVerificationStatus.maxAttempts:
    // show support options
    break;
  default:
    // handle other outcomes
}
```

{% endstep %}
{% endstepper %}

### Result Values

`VoveVerificationStatus` can be:

* `success`
* `pending`
* `canceled`
* `maxAttempts`

When `exitAfterEachStep` is `true`, `result.nextStep` indicates the next action (`ID_DOCUMENT`, `LIVENESS`, `ADDRESS_PROOF`, `CAR_REGISTRATION_DOCUMENT`, `DRIVING_LICENSE`, `DONE`, or `unknown`).

## Configuration Options

| Field                  | Type            | Default | Description                                                                                             |
| ---------------------- | --------------- | ------- | ------------------------------------------------------------------------------------------------------- |
| `showUI`               | `bool`          | `true`  | Displays Vove’s built-in welcome/summary screens. Disable to provide your own UI.                       |
| `exitAfterEachStep`    | `bool`          | `false` | Returns control after each step (e.g., `ID_DOCUMENT`, `LIVENESS`) so you can interleave your own flows. |
| `onMaxAttemptsReached` | `VoidCallback?` | `null`  | Invoked when the user reaches the maximum verification attempts.                                        |
| `locale`               | `VoveLocale?`   | `en`    | Overrides the SDK UI language (`en`, `fr`, `ar`, `de`, `arMA`).                                         |
| `enableVocalGuidance`  | `bool?`         | `false` | Plays voice instructions during the 3D liveness step.                                                   |

## Troubleshooting

| Issue                                    | Fix                                                                                                      |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `VoveStartConfiguration` not found (iOS) | Run `pod repo update && pod install` so `VoveSDK` ≥ 1.5.0 is fetched.                                    |
| Session token rejected                   | Confirm your backend uses Vove’s Verification Session API and you’re passing the fresh token unmodified. |
