---
title: 接收结果
canonical: https://developer.unico.io/zh-CN/dual-api/developers/sdks-and-tools/flutter/capture-flow/receiving-the-result
locale: zh-CN
generated_by: markdown-export
---

SDK 通过在采集会话期间所使用的监听器接口中定义的回调来返回采集结果。

## UnicoSelfie

****`onSuccessSelfie`****

当图像成功采集时调用。返回一个包含以下内容的 `ResultCamera` 对象：

  - **`base64`** — 已采集的图像；可用于在您的应用中显示预览。
  - **`encrypted`** — JWT 载荷，必须发送至您的后端以通过 REST API 完成生物特征验证。

  ```dart
  @override
  void onSuccessSelfie(ResultCamera result) {
    final base64 = result.base64;
    final encrypted = result.encrypted; // JWT to send to your backend
  }
  ```

  :::danger[`encrypted` 使用说明]
  - `encrypted` 属性严格用于通过 Client API 发送图像。不得对其进行解析、序列化或修改——其特性可能在未提前通知的情况下发生变更。必须在采集后 **10 分钟**内将其发送至 API。Unico 对因不当处理而造成的任何损失概不负责。
  - `base64`/`encrypted` 文件的大小可能因设备质量、生成的照片大小以及 Unico 的业务规则而有所不同。**请勿在您的编程逻辑或基础设施中限制** SDK 生成的字符串大小。
  :::

  :::tip[Base64 转 bitmap（Android）]
  如果需要在 Android 上将 `base64` 转换为 bitmap，标准方法无法直接使用——需要先以逗号（`,`）分割字符串。请参阅 [How to convert a Base64 string into a Bitmap image to show it in an ImageView?](https://stackoverflow.com/questions/4837110/how-to-convert-a-base64-string-into-a-bitmap-image-to-show-it-in-a-imageview)。
  :::

****`onErrorSelfie`****

当采集过程中发生错误时调用。返回包含 `getCode()` 和 `getDescription()` 的 `UnicoError` 对象。有关完整的错误代码列表，请参阅[错误处理](/developers/sdks-and-tools/flutter/error-handling)。

  ```dart
  @override
  void onErrorSelfie(UnicoError error) {
    final code = error.getCode();
    final description = error.getDescription();
  }
  ```

## UnicoDocument

****`onSuccessDocument`****

当证件图像成功采集时调用。返回一个包含以下内容的 `ResultCamera` 对象：

  - **`base64`** — 已采集的图像；可用于显示预览。
  - **`encrypted`** — JWT 载荷，必须在 **10 分钟内**发送至您的后端，且不得对其进行修改或反序列化。

  ```dart
  @override
  void onSuccessDocument(ResultCamera result) {
    final base64 = result.base64;
    final encrypted = result.encrypted; // JWT to send to your backend
  }
  ```

****`onErrorDocument`****

当证件采集过程中发生错误时调用。返回一个 `UnicoError` 对象。有关完整的错误代码列表，请参阅[错误处理](/developers/sdks-and-tools/flutter/error-handling)。

  ```dart
  @override
  void onErrorDocument(UnicoError error) {
    final code = error.getCode();
    final description = error.getDescription();
  }
  ```