id_doc_kit 1.0.0 copy "id_doc_kit: ^1.0.0" to clipboard
id_doc_kit: ^1.0.0 copied to clipboard

Indian ID validation helpers for KYC and onboarding (Aadhaar, PAN, GSTIN, DL, Voter ID, Passport + PIN/Phone/Email).

id_doc_kit #

A lightweight, production-ready Flutter/Dart package for validating Indian ID documents used in KYC, onboarding, and fintech workflows.

Built with a strict core architecture, structured results, and developer-friendly UI helpers.

๐Ÿš€ Live Demo #

Try it out in your browser! ๐Ÿ‘‰ View Live Demo

The demo showcases all supported document types with real-time validation feedback, automatic formatting, and metadata extraction.


โœจ Supported Documents #

โœ… Aadhaar (12-digit UID & 16-digit VID with Verhoeff Checksum)
โœ… PAN (with Holder Type detection - Individual, Company, Trust, etc.)
โœ… GSTIN (with State detection)
โœ… Driving License (Strict RTO rules + Legacy support + Fallback logic)
โœ… Voter ID (EPIC)
โœ… Passport
โœ… PIN Code (India)
โœ… Phone Number (India - handles +91 prefix)
โœ… Email


๐Ÿ›  Key Features #

  • ๐Ÿ“ฆ Structured Results: Returns IdDocumentResult with error codes, human-friendly messages, and metadata.
  • โŒจ๏ธ Smart Formatters: Built-in TextInputFormatter for auto-spacing (Aadhaar) and case correction (PAN/GSTIN) with cursor preservation.
  • ๐Ÿ” Auto Detection: Identify the document type automatically from a raw string using validateAuto.
  • ๐Ÿท Metadata Extraction: Parse state codes, RTO numbers, holder types, and issuance years.
  • ๐Ÿ’ฌ Friendly Messages: Pre-configured human-readable messages via the friendlyMessage extension.
  • ๐Ÿง  Confidence Scores: Deterministic scoring (0.0 to 1.0) for validation certainty.

๐Ÿ“ฆ Result Structure #

IdDocumentResult {
  type,            // IdDocumentType.pan, .aadhaar, etc.
  isValid,         // Boolean
  rawValue,        // Original input
  normalizedValue, // Stripped of spaces/formatting
  metadata,        // Map containing State, RTO, Holder Type, etc.
  confidence,      // 0.0 to 1.0
  errorCode,       // Machine-readable (e.g., 'PAN_INVALID_FORMAT')
  errorMessage     // Raw technical error
}

// UI Extension for human-readable feedback
print(result.friendlyMessage); // "Invalid PAN format. Example: ABCDE1234F"

โŒจ๏ธ Real-time Input Formatting #

Enhance UX by applying formatters directly to your TextFormField. These formatters handle cursor position preservation and real-time cleanup.

Document Formatting Logic Keyboard Type
Aadhaar 1234 5678 9012 (Auto-space) Number
PAN ABCDE1234F (Auto-uppercase) Text (Capitalized)
Phone Strips non-digits, handles +91 Phone

Direct usage:

TextFormField(
  inputFormatters: [IdInputFormatters.getFormatter(IdDocumentType.aadhaar)],
  keyboardType: TextInputType.number,
);

๐ŸŽจ UI Widgets #

1. IdTextField (Quickest Integration) #

A specialized TextFormField that handles formatting, keyboard types, capitalization, and validation automatically.

IdTextField(
  type: IdDocumentType.pan,
  autoFormat: true,
  decoration: InputDecoration(labelText: "Enter PAN"),
  onValidationChanged: (isValid) {
    setState(() => isPanValid = isValid);
  },
)

2. IdField (Custom UI Builder) #

Use this for full UI control while the library manages the logic, formatting, and result state.

IdField(
  type: IdDocumentType.aadhaar,
  builder: (context, controller, result) {
    return Column(
      children: [
        TextField(controller: controller),
        if (result != null && !result.isValid)
          Text(result.friendlyMessage, style: TextStyle(color: Colors.red)),
      ],
    );
  },
);

๐Ÿงช Advanced Logic #

Smart Auto-Detection:

// Input: "ABCDE1234F"
final result = IdValidator.instance.validateAuto(input);
print(result.type); // IdDocumentType.pan

Metadata Extraction:

final result = IdValidator.instance.validate(type: IdDocumentType.pan, value: input);

// Access parsed metadata
final holder = result.metadata?['holderType']; // 'Individual', 'Company', etc.
final state = result.metadata?['stateName'];    // 'Karnataka' (for DL/GSTIN)

๐Ÿ” Disclaimer #

This package performs format and structural validation (checksums, regex, and patterns). It does not verify the identity against government databases (UIDAI, NSDL, etc.).

โ˜• Support & Sponsorship #

If id_doc_kit saves you development time or helps in production, consider supporting its development.

Buy Me a Coffee
2
likes
150
points
114
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Indian ID validation helpers for KYC and onboarding (Aadhaar, PAN, GSTIN, DL, Voter ID, Passport + PIN/Phone/Email).

Repository (GitHub)
View/report issues

Topics

#india #kyc #aadhaar #pan #gstin

License

MIT (license)

Dependencies

flutter

More

Packages that depend on id_doc_kit