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

# Flutter SDK

> Run the idto verification flow in a Flutter app on Android and iOS with one awaited call.

The Flutter package `idto_flutter` pushes a full-screen route that runs the idto verification flow, reports each step to your callbacks, and returns a typed result when the user is done.

![Bank account entry screen](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-bank-entry.png)

The bank account step.

## Requirements

| Item | Value |
| - | - |
| Dart SDK | 3.10 or later |
| Flutter | 3.38 or later |
| Platforms | Android and iOS |
| Device | A real device for document and selfie capture |

You also need a `client_id` and `client_secret` (kept on your server), a `workflowTemplateId`, and a backend route that mints a client token. See [Authentication](https://idto.mintlify.site/authentication.md).

## Install

```yaml theme={null}
dependencies:
  idto_flutter: ^0.4.1
```

Or run `flutter pub add idto_flutter`.

## Permissions

The app declares and requests camera and microphone access. Without the runtime grant on Android, the camera step shows a black screen and no prompt.

iOS, in `ios/Runner/Info.plist`:

```xml theme={null}
<key>NSCameraUsageDescription</key>
<string>Camera access is required to verify your identity.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for the liveness check.</string>
```

Android, in `android/app/src/main/AndroidManifest.xml` inside `<manifest>`:

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

Then request both before you open the flow, for example with `permission_handler` (the SDK does not bundle it):

```dart theme={null}
await [Permission.camera, Permission.microphone].request();
```

## Quick start

**1. Mint a client token on your server**

Your server calls `POST /auth/sdk/token` with `client_id` and `client_secret` and returns only `access_token` to the app. Recipes: [Node](https://idto.mintlify.site/recipes/sdk-token-node-express.md), [Python](https://idto.mintlify.site/recipes/sdk-token-python-fastapi.md), [Go](https://idto.mintlify.site/recipes/sdk-token-go-gin.md).

**2. Open the flow**

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

Future<void> verify(BuildContext context, String clientToken) async {
  final result = await IDto.open(
    context,
    config: IDtoConfig(
      clientToken: clientToken,
      workflowTemplateId: 'your-workflow-template-uuid',
      businessName: 'Sample Traders',
      env: IDtoEnv.production,
    ),
    getToken: fetchClientToken,
    onStepComplete: (d) => debugPrint('step ${d.step}'),
    onError: (e) => debugPrint('${e.step}: ${e.error}'),
  );
  if (result.status == IDtoStatus.completed) {
    await confirmOnServer(result.sessionToken);
  }
}
```

`IDto.open` resolves when the user closes the flow, abandons it, or it fails to start. After the last step, `onWorkflowComplete` fires and the completion screen stays up until the user closes it; the result then has `status` `IDtoStatus.completed`. A second `IDto.open` while one is running throws `StateError`.

**3. Confirm the result on your server**

Callbacks drive your UI only. Confirm the session from your server with the [session result recipe](https://idto.mintlify.site/recipes/confirm-session-result.md) or a signed [webhook](https://idto.mintlify.site/concepts/webhooks.md) before you grant access.

![Bank account verified screen](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-bank-verified.png)

The bank account result.

## `IDto.open` parameters

| Parameter | Type | Purpose |
| - | - | - |
| `context` | `BuildContext` | Where the route is pushed. |
| `config` | `IDtoConfig` | Required. See below. |
| `onStepComplete` | `void Function(IDtoStepData)` | After each step. |
| `onWorkflowComplete` | `void Function(IDtoWorkflowCompleteData)` | When every step is done. |
| `onError` | `void Function(IDtoErrorData)` | When a step or the session start fails. |
| `onAbandon` | `void Function(IDtoAbandonData)` | When the user leaves from an error screen. |
| `getToken` | `Future<String> Function()` | Returns a fresh client token when the current one expires. |
| `closeSignal` | `ValueNotifier<int>` | Change its value to close the flow from your code. |

The returned `IDtoResult` has `status` (`completed`, `closed`, `abandoned` or `error`), `sessionToken`, `accumulatedData` and, on failure, `error`.

## Configuration

`IDtoConfig(clientToken:, workflowTemplateId:)` is required. Every other field is optional.

| Field | Type | Purpose |
| - | - | - |
| `sessionToken` | `String?` | Resume an earlier session. |
| `startFresh` | `bool?` | Start a new session even if one is in progress. |
| `merchantUserId` | `String?` | Your own id for this user. |
| `phone` | `String?` | Prefills the mobile number step. |
| `preVerified` | `Map<String, bool>?` | Module slugs you already verified, which the flow skips. |
| `skippable` | `List<String>?` | Module slugs the user may skip. See [Modules](https://idto.mintlify.site/sdks/modules.md). |
| `accumulatedData` | `Map<String, dynamic>?` | Data you already hold, passed into the session. |
| `referenceName` | `String?` | Name every document name is matched against. |
| `nameMatchConfig` | `IDtoNameMatchConfig?` | Threshold, decision mode (`all` or `any`), honorifics, aliases, compare pairs. |
| `faceMatchReferenceImage` | `String?` | Reference photo for face match. |
| `faceMatchConfig` | `IDtoFaceMatchConfig?` | Skip liveness, threshold, liveness failure policy. |
| `aadhaarConfig` | `IDtoAadhaarConfig?` | DigiLocker failure limit, OKYC on or off. |
| `panConfig` | `IDtoPanConfig?` | Skip the PAN context screen. |
| `businessName` | `String?` | Your name in the flow header. |
| `logo` | `String?` | URL of your logo. |
| `language` | `IDtoLanguage` | `en` or `hi`. |
| `theme` | `IDtoTheme` | `light` or `dark`. |
| `displayMode` | `IDtoDisplayMode` | `fullScreen` or `bottomSheet`. |
| `desktopModal`, `bottomSheet` | objects | Size limits for each display mode. |
| `env` | `IDtoEnv` | `production` (default, `https://prod.idto.ai`) or `development` (staging, `https://dev.idto.ai`). |
| `baseUrl` | `String?` | Overrides the API host. |
| `colors` | `IDtoColors?` | Colour overrides. |
| `readyTimeout` | `Duration` | How long to wait for the flow to load. Default 30 seconds. |
| `allowedHosts` | `List<String>` | Extra hostnames the flow may navigate to. |
| `debug` | `bool` | Prints the flow's log messages. |

## Callback payloads

| Type | Fields |
| - | - |
| `IDtoStepData` | `step`, `result`, `accumulatedData`, `sessionToken`, `creditsDeducted`, `balanceRemaining` |
| `IDtoWorkflowCompleteData` | `allSteps`, `accumulatedData`, `sessionToken` |
| `IDtoErrorData` | `step`, `error`, `sessionToken` |
| `IDtoAbandonData` | `atStep`, `reason`, `sessionToken` |

## See it run

<video controls width="100%" src="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-bank.mp4" poster="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-bank.jpg" />

Was this page helpful? Email us at [tech@idto.ai](mailto:tech@idto.ai?subject=Docs%20feedback%3A%20Flutter%20SDK) with the page link.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.