---
title: Liveness (biometric selfie)
canonical: https://developer.unico.io/dual-api/developers/sdks-and-tools/flutter/capture-flow/capture-types/liveness
locale: en
generated_by: markdown-export
---

Biometric selfie capture with embedded liveness verification. The SDK guides the user until a biometrically valid frame is obtained via SmartFrames and returns the image as Base64 + JWT.

:::secondary[Capability]
This capture type uses the **Liveness** capability. For a conceptual overview of how Liveness works, refer to the Liveness capability page.
:::

## How it works

The plugin delegates to the underlying native SDKs:

1. The plugin opens the camera (Android or iOS) with the SmartFrame overlay.
2. The native SDK guides the user to position their face within the frame.
3. Validates liveness — the session only completes when the user is physically present.
4. Returns a `ResultCamera` object with `base64` and `encrypted` (JWT) via the platform channel.

## Camera mode (smart capture)

The SDK has **intelligent framing** and **automatic capture** enabled by default. Configure the camera mode in your builder as follows:

```dart
UnicoCheckCameraOpener _opener = _unicoCheck
    .setAutoCapture(autoCapture: true)
    .setSmartFrame(smartFrame: true)
    .build();
```

## Starting a liveness capture

****Step 2** — Implement the selfie listeners on `UnicoSelfie`**

Add the selfie callbacks to your state class:

  | Method | Description |
  |---|---|
  | `onSuccessSelfie(ResultCamera result)` | Capture succeeded — returns `ResultCamera` with `base64` (preview) and `encrypted` (JWT for the API) |
  | `onErrorSelfie(UnicoError error)` | Capture failed — returns a `UnicoError` with code and description |

  :::warning[Token expiry]
  The interval between generating `encrypted` and submitting it to the API must not exceed **10 minutes**.
  :::

  ```dart
  class _MyHomePageState extends State<MyHomePage>
      implements UnicoSelfie {

    @override
    void onSuccessSelfie(ResultCamera result) { }

    @override
    void onErrorSelfie(UnicoError error) { }

  }
  ```

****Step 3** — Call `openCameraSelfie`**

The `openCameraSelfie` method opens the camera. It takes the implementation of the `UnicoSelfie` listener:

  ```dart
  _opener.openCameraSelfie(listener: this);
  ```

## Monitoring data collection

The `openCameraSelfie` method provides an overload that accepts metadata via `UnicoCheckPrepareInfo` to assist in identifying the user session and the flow:

- `externalUserId` (String, **required**) — User identifier within your system. Automatically hashed using SHA-256 before transmission.
- `useCase` (String, optional) — Identifier for the context or flow currently running. Transmitted in plain text.

```dart
_opener.openCameraSelfie(
  listener: this,
  prepareInfo: UnicoCheckPrepareInfo(
    externalUserId: 'external_user_id',
    useCase: 'use_case', // optional
  ),
);
```

For the full result handling, see [Receiving the result](/developers/sdks-and-tools/flutter/capture-flow/receiving-the-result).