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 UI-friendly helpers.
๐ Live Demo
Try it out in your browser! ๐ View Live Demo
The demo showcases all supported document types with real-time validation feedback.
โจ Supported Documents
โ Aadhaar
โ PAN
โ GSTIN
โ Driving License (strict + fallback)
โ Voter ID (EPIC)
โ Passport
โ PIN Code (India)
โ Phone Number (India)
โ Email
This makes id_doc_kit one of the most complete, developer-friendly Indian document validation packages on pub.dev.
โจ Key Features
- โ Structured Validation Results:
IdDocumentResult {
type,
rawValue,
normalizedValue,
isValid,
errorCode,
errorMessage,
confidence,
meta
}
๐ง Confidence Score (NEW)
Each validation result includes a confidence score (0.0 โ 1.0) indicating structural certainty.
| Scenario | Confidence |
|---|---|
| Strict deterministic validation (PAN, Aadhaar, Passport) | 1.0 |
| Strong structure, no checksum (GSTIN, Phone, Email, PIN) | 0.9 โ 0.95 |
| Driving License fallback validation | 0.6 |
| Invalid | 0.0 |
โ ๏ธ Important:
Confidence represents structural validation only. This package does NOT verify documents against government databases.
๐งฉ Metadata (meta) for Advanced Use Cases
Validators expose parsed data via the meta field.
Example (Driving License):
meta: {
"stateCode": "KA",
"stateName": "Karnataka",
"rto": "01",
"year": 2021,
"serial": "0001234",
"isLegacy": false,
"isFallback": false
}
๐ชช Driving License Validation (Important)
Driving Licenses are validated in two stages:
1๏ธโฃ Strict Validation (Preferred)
- Validates state/UT code
- RTO range
- Year bounds
- Legacy handling
- Returns confidence = 1.0
2๏ธโฃ Fallback Validation
- Structural format match only
- Used when strict validation fails
- Returns confidence = 0.6
- Clearly marked via meta.isFallback = true
This ensures maximum compatibility with real-world data while maintaining transparency.
๐งช Example Usage
final result = IdValidator.instance.validate(
type: IdDocumentType.pan,
value: 'ABCDE1234F',
);
if (result.isValid && result.confidence >= 0.9) {
// Safe to proceed
}
๐จ UI-Friendly Widgets
Quick integration:
IdTextField(
type: IdDocumentType.pan,
onValidationChanged: (isValid) {},
);
Full control:
IdField(
type: IdDocumentType.aadhaar,
builder: (context, controller, result) {
return TextField(
controller: controller,
decoration: InputDecoration(
errorText: result?.errorMessage,
),
);
},
);
๐ง Design Principles
- No standalone functions
- Single validation entry point
- Strict base architecture
- No backend calls
- No UI assumptions
- Fully testable
๐ Use Cases
- KYC onboarding
- Fintech apps
- Identity verification
- Form validation
- Government document input
๐ Disclaimer
This package performs format and structural validation only. It does not confirm document ownership or authenticity with issuing authorities.
๐ฆ Installation
Add this to your pubspec.yaml:
dependencies:
id_doc_kit: ^0.0.8