Skip to main content
Integrate DigiLocker document retrieval into your Flutter app using the native SDK. The SDK provides an embedded interface that works on both iOS and Android.

View on pub.dev

Check out the package on pub.dev for latest version and updates
1

Create a session

Before initializing the SDK, you must create a unique session. Each SDK instance requires its own session to ensure secure and independent interactions.Use the Create Session endpoint to generate this session. This is a server-side API call that uses Sandbox Authentication to validate your credentials.Once created, you’ll receive a session_id, which you’ll need when initializing the SDK on the client side.
2

Install the package

Add the DigiLocker SDK package to your Flutter project.
Or add it manually to your pubspec.yaml:
Requirements: Flutter SDK ^3.10.1
3

Integrate the SDK

Import the SDK, set your API key, configure options, and launch the DigiLocker flow.

3.1 Basic implementation

string
required
Unique session ID generated when Create Session API is called.
object
required
Configuration for branding displayed in the DigiLocker interface.
object
required
Appearance configuration for the SDK.
4

Handle SDK events

Set up an event listener to handle SDK events indicating session completion or cancellation.
To programmatically verify the final status of a session, call the Session Status endpoint from your backend.

Event types

The SDK emits the following event types via the EventListener:

API reference

DigilockerSDK

The main SDK class that provides a singleton instance. Methods: setAPIKey(String apiKey)
  • Sets the API key required to authenticate requests
  • Parameters: apiKey (String) - The API key string starting with “key_”
  • Throws: Exception if the API key does not start with “key_”
open(BuildContext context, Map options)
  • Opens the SDK UI with the provided configuration
  • Parameters:
    • context (BuildContext) - The BuildContext from which the SDK is accessed
    • options (Map) - Configuration options including session_id, brand, and theme
  • Throws: Exception if API key or required options are not set
setEventListener(EventListener eventListener)
  • Registers an event listener to receive SDK events
  • Parameters: eventListener (EventListener) - The event listener to register

EventListener

Interface for receiving SDK events. Methods: onEvent(Map event)
  • Called when an SDK event occurs
  • Parameters: event (Map) - The event data containing event type and payload

Next steps

Create Session API

Learn how to create sessions for the SDK

Session Status API

Monitor session progress and status

Get Document API

Retrieve document data after completion