View on pub.dev
Check out the package on pub.dev for latest version and updates
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.Install the package
Add the DigiLocker SDK package to your Flutter project.Or add it manually to your Requirements: Flutter SDK ^3.10.1
pubspec.yaml:Integrate the SDK
Import the SDK, set your API key, configure options, and launch the DigiLocker flow.
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 theEventListener:
| Event Type | Description |
|---|---|
in.co.sandbox.kyc.digilocker_sdk.session.completed | User successfully completed the DigiLocker flow and documents were retrieved |
in.co.sandbox.kyc.digilocker_sdk.session.closed | User closed the SDK without completing the flow |
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 accessedoptions(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