DigiLocker Flutter SDK

A Flutter plugin for Surepass DigiLocker SDK that enables seamless DigiLocker verification in your Flutter apps. Verify Aadhaar and fetch documents from DigiLocker with just a few lines of code.

Features

  • ✅ Easy DigiLocker integration
  • ✅ Aadhaar verification
  • ✅ Document fetching from DigiLocker
  • ✅ Auto-fill Aadhaar number
  • ✅ Auto-select consent checkboxes
  • ✅ Sandbox and Production environments
  • ✅ Android and iOS support
  • ✅ Simple callback-based API

Installation

Add this to your pubspec.yaml:

dependencies:
  digilocker_flutter_sdk: ^1.0.5

Then run:

flutter pub get

Platform Setup

Android

Ensure minSdkVersion is 28 or higher in android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 28
    }
}

iOS

Ensure iOS deployment target is 13.0 or higher. Run:

cd ios && pod install && cd ..

Quick Start

1. Import the package

import 'package:digilocker_flutter_sdk/digilocker_sdk.dart';

2. Start verification

await DigilockerSdk.start(
  context: context,
  apiToken: 'your_api_token_here',
  environment: Environment.sandbox,
  onComplete: (result) {
    if (result.success) {
      print('✅ Verification successful!');
      print('Data: ${result.data}');
    } else {
      print('❌ Verification failed: ${result.message}');
    }
  },
  onError: (error) {
    print('Error: $error');
  },
);

That's it! 🎉

Complete Example

import 'package:flutter/material.dart';
import 'package:digilocker_flutter_sdk/digilocker_sdk.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DigiLocker Demo',
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  void _startVerification(BuildContext context) async {
    await DigilockerSdk.start(
      context: context,
      apiToken: 'your_api_token_here',
      environment: Environment.sandbox,
      onComplete: (result) {
        if (result.success) {
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(content: Text('✅ Verification successful!')),
          );
        } else {
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(content: Text('❌ ${result.message}')),
          );
        }
      },
      onError: (error) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Error: $error')),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('DigiLocker Demo')),
      body: Center(
        child: ElevatedButton(
          onPressed: () => _startVerification(context),
          child: Text('Start Verification'),
        ),
      ),
    );
  }
}

API Reference

DigilockerSdk.start()

Starts the DigiLocker verification flow.

Parameter Type Required Description
context BuildContext Yes Flutter context for navigation
apiToken String Yes Your Surepass API token
environment Environment No Environment.sandbox or Environment.production (default: sandbox)
onComplete Function(VerificationResult) No Callback when verification completes
onError Function(String) No Callback for error handling

VerificationResult

Property Type Description
success bool Whether verification was successful
message String? Status message
data Map? Verification data (token, documents, etc.)

Environment

  • Environment.sandbox - For testing
  • Environment.production - For live use

Advanced Features

Auto-fill Aadhaar Number

The SDK automatically fills the Aadhaar number if provided in the API token configuration.

Configure auto_selection_check_box in your API options to automatically select specific document checkboxes:

{
  "auto_selection_check_box": ["PAN Verification Record", "Driving License"]
}

The Aadhaar card checkbox is always selected by default.

Requirements

  • Flutter: >=3.0.0
  • Dart: >=3.0.0 <4.0.0
  • Android: minSdkVersion 28
  • iOS: 13.0+

Troubleshooting

Common Issues

Issue Solution
Build error on Android Ensure minSdkVersion 28 in android/app/build.gradle
Build error on iOS Run cd ios && pod install && cd ..
Invalid token Check your API token from Surepass dashboard
Network error Ensure device has internet connectivity
Verification failed Check if you're using correct environment (sandbox/production)

Need Help?

For support, contact:

What's New

v1.0.5

  • Fixed the keyboard issue in iOS 26.3.1
  • Improved WebView behavior when input fields are focused

v1.0.4

  • 🐛 Fixed navigation back button error handling
  • ♻️ Refactored code for better maintainability
  • ⚡ Bug fixes and stability improvements

v1.0.3

  • ✨ Added support for auto_selection_check_box parameter
  • ✨ Auto-select additional consent checkboxes based on API configuration
  • 🐛 Improved checkbox selection logic
  • 📝 Updated README with simpler integration guide

See CHANGELOG.md for full history.

License

Copyright © 2026 Surepass. All rights reserved.

Publisher

Published by surepass.io - Verified Publisher on pub.dev