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.flutter-io.cn.
β¨ 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.
β Support & Sponsorship
If id_doc_kit saves you development time or helps in production,
consider supporting its development.
Your support helps maintain accuracy, documentation, and long-term maintenance.