# Implementation Guide

### Authentication

A unique access token should be created upon each SDK entry. In order to generate an access token, please refer to Valify's [Authentication](https://valify.gitbook.io/documentation/apis/oauth-token) Documentation.

{% hint style="warning" %}
**Security Warning:** For improved security, consider implementing the access token fetching logic outside the Activity. This helps keep sensitive credentials secure and reduces potential exposure within the Activity/Fragment code.
{% endhint %}

### Importing

Import the module’s function in your file using the following line

```dart
import 'package:vidvocr_flutter_plugin/vidvocr_flutter_plugin.dart';
```

### Configurations

The plugin builder is separated into two components.

#### Required Configurations

Initialize the required parameters as follows while adding the required configurations

```dart
  final String baseURL = ' '; //put your acctual base url here
  final String bundleKey = ' '; //put your actual bundle key here
  final String accessToken = ' '; //put your actual access token here

```

#### Optional Configurations

Initialize the required parameters as follows while adding the desired configurations

<pre class="language-dart"><code class="lang-dart">final String language = "&#x3C;insert_language>"; // "en" is set as default
final bool document_verification = &#x3C;boolean>; // false is set as default
final bool collect_user_info = &#x3C;boolean>; // false is set as default
final bool document_verification_plus = &#x3C;boolean>; // false is set as default
final bool advanced_confidence = &#x3C;boolean>; // false is set as default
final bool profession_analysis = &#x3C;boolean>; // false is set as default
final bool review_data = &#x3C;boolean>; // default is true
final bool preview_captured_image = &#x3C;boolean>; //default is false
final bool manual_capture_mode = &#x3C;boolean>; //default is false
final bool capture_only_mode = &#x3C;boolean>; // default is false
final String primary_color = ”&#x3C;hex_color_code>”; //default is valify default color
final bool disable_valify_logo = &#x3C;boolean>; //default is false
final String custom_logo = "&#x3C;base_64_image>";
<strong>final bool enable_logging= &#x3C;boolean>; // default false
</strong>final HashMap&#x3C;String, String> headers = HashMap();//default empty
</code></pre>

### Configurations Breakdown

This section shows the breakdown of all optional builder configurations.&#x20;

1. The following line is where the user interface language is set.&#x20;

```dart
final String language = "<insert_language>"; // ["ar" or "en"] 
```

{% hint style="info" %}
The currently supported languages are Arabic and English
{% endhint %}

2. If this flag is set to **true**, the SDK performs additional **data validations** on the document.\
   These validations are returned in the SDK response as **flags**, and **you must implement your own handling logic based on these flags** [**\[Handling Document Verification Plus  Flags in Code\]**](/valify-ios-sdk-documentation/document-capture/android-native-sdk/sdk-response.md#document-verification-plus-case-handling) , the SDK does not auto-reject or block the transaction.

   &#x20;View Document Verification Plus Breakdown here: [**\[Understanding Document verification plus flag\]**](https://valify.gitbook.io/documentation/apis/egy-nid-ocr/egy-nid-ocr#document-verification-plus-breakdown)

```dart
final bool document_verification_plus = <boolean>;
```

3. If this flag is set to **true**, the SDK detects **potential physical or digital manipulation in the National ID**. These validations are returned in the SDK response as **flags**, and **you must implement your own handling logic based on these flags**[ **\[Handling Advanced Confidence Flags in Code\]** ](https://valify.gitbook.io/valify-ios-sdk-documentation/document-capture/flutter-plugin/plugin-response#advance-confidence-case-handling), the SDK does not auto-reject or block the transaction.

   &#x20;View Advanced Confidence Breakdown here: [**\[Understanding Advanced Confidence flag\]**](https://valify.gitbook.io/documentation/kyc/kyc-documents/egy-nid-ocr/egy-nid-ocr#advanced-confidence-breakdown)

```dart
final bool advanced_confidence = <boolean>;
```

4. If the following line is set to true, the captured image will be displayed for the user.

```dart
final bool preview_captured_image = <boolean>;
```

5. If the following line is set to true, the SDK will automatically enable manual capture if it detects that the user is unable to autocapture card.

```dart
final bool manual_capture_mode = <boolean>;
```

6. If the following line is set to true, a screen is added to the user flow that displays the images captured and the OCR result to the user.

```dart
final bool review_data = <boolean>;
```

7. If the following line is set to true, the SDK purely performs image capturing and only returns these images in the SDK response.

```dart
final bool capture_only_mode = <boolean>;
```

8. The following line is optional and can be used to receive event logs from the SDK experience to be used for user behavior analysis.&#x20;

```dart
final bool enable_logging= <boolean>;
```

9. The following line is optional and can be used to set your company's branding color to the SDK's user interface.

```dart
final String primaryColor = ”<hex_color_code>”;
```

10. If the following line is set to `true`, the Valify logo will be hidden from the SDK user interface.

```dart
final bool disable_valify_logo = <boolean>;
```

11. The following line can be used to display a custom logo instead of the default Valify logo. The value should be a base64-encoded image string.

<pre class="language-dart"><code class="lang-dart"><strong>final String custom_logo = "&#x3C;base_64_image>";
</strong></code></pre>

12. The following line is optional and can be used to set any headers that may be required for purposes specific to your application. Any headers set will be sent along with each API call made by the SDK.&#x20;

```dart
final HashMap<String, String> headers = HashMap();
```

### Parameter Declaration

Declare the SDK parameters with the configuration variables previously created

<pre class="language-dart"><code class="lang-dart">Map&#x3C;String, dynamic> params = {
  "base_url": baseURL,
  "access_token": accessToken,
  "bundle_key": bundleKey,
  "language": language,
  "document_verification": document_verification,
  "review_data": review_data,
  "capture_only_mode": capture_only_mode,
  "manual_capture_mode": manual_capture_mode,
  "preview_captured_image": preview_captured_image,
  "primary_color": primary_color,
  "disable_valify_logo": disable_valify_logo,
<strong>  "custom_logo": custom_logo,
</strong>  "enable_logging": enable_logging,
  "collect_user_info": collect_user_info,       
  "advanced_confidence": advanced_confidence,     
  "profession_analysis": profession_analysis,     
  "document_verification_plus": document_verification_plus,
  "headers": headers
};
</code></pre>

### Start the SDK

Use the following code snippet to run the plugin

```dart
    try {
      final String? result = await VidvocrFlutterPlugin.startOCR(params);
        //handle logic to use the liveness response depending on the state    
    } on PlatformException catch (e) {
        //catch errors here
    }
```

### Sample Integration Example

Check out our [GitHub repository](https://github.com/Valify-Solutions/Flutter_VIDOCR_LIVENESS_Simple_Integration_App) for a simple integration app demonstrating how to use our SDK. The repository includes step-by-step instructions and sample code to help you get started quickly.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://valify.gitbook.io/valify-ios-sdk-documentation/document-capture/flutter-plugin/implementation-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
