id_doc_kit 0.0.8
id_doc_kit: ^0.0.8 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 toolkit for validating
Indian ID documents with structured results and flexible form field support.
Perfect for KYC, onboarding, fintech, business verification, and identity apps.
๐ 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 (with Verhoeff checksum)
- โ PAN
- โ Driving License (basic format)
- โ GSTIN (basic structure + state code)
- โ Voter ID (EPIC) โ 2โ3 letters + 7 digits
- โ Passport (Indian) โ 1 letter + 7 digits
- โ Phone number (India)
- โ PIN code (India)
- โ Email (basic format)
This makes id_doc_kit one of the most complete, developer-friendly Indian document validation packages on pub.dev.
โจ Key Features #
-
โ Structured validation results
isValidnormalizedValueerrorCode(e.g.INVALID_FORMAT,INVALID_LENGTH,INVALID_CHECKSUM)errorMessage(human-friendly)
-
โ Single unified validator API
IdValidator.instance.validate(type: ..., value: ...)IdValidator.instance.validateAuto(value)(optional)
-
โ Three flexible ways to handle input fields
idFormFieldValidatorโ logic onlyIdTextFieldโ ready-to-use widgetIdFieldโ fully custom UI via builder
-
๐ Consistent behavior across Aadhaar, PAN, DL, GSTIN, Voter ID, Passport
-
๐ซ No external APIs (offline, fast, privacy-safe)
-
๐ Works on Android, iOS, Web
-
๐งช Well-tested & null-safe
We validate driving licenses using a two-step approach:
- Comprehensive state-aware validation (
DrivingLicenseStateValidator)
- Validates: state code, RTO, year (1988..currentYear+1), serial.
- Options:
requiredState,strictMode,allowLegacyCodes.
- Fallback permissive validation
- Applies a looser format (SS + RTO + YYYY + serial) only if comprehensive validation fails.
- Important: fallback also validates the parsed year and serial to avoid false positives (error codes:
DL_FALLBACK_YEAR_INVALID,DL_FALLBACK_SERIAL_INVALID).
Usage examples:
// Simple: package-level validator
final res = IdValidator.instance.validate(IdDocumentType.drivingLicense, 'KA0120210001234');
if (res.isValid) {
print('Normalized: ${res.normalizedValue}');
} else {
// show UI-friendly message
print(res.friendlyMessage);
}
// Strict mode (server-side)
final full = DrivingLicenseStateValidator.validate(
'OR0120150001234',
strictMode: true,
allowLegacyCodes: false,
);
if (!full.isValid) {
print(full.errorMessage);
}
Formatting & autoFormat #
id_doc_kit now includes IdFormatter for UI-friendly formatting and an autoFormat toggle on text fields.
IdFormatter #
Use to normalize/format values consistently in UI:
import 'package:id_doc_kit/id_doc_kit.dart';
final panFormatted = IdFormatter.format(IdDocumentType.pan, 'abcde1234f'); // ABCDE1234F
final aadhaarFormatted = IdFormatter.format(IdDocumentType.aadhaar, '123456789012'); // 1234 5678 9012
๐ฆ Installation #
Add this to your pubspec.yaml:
dependencies:
id_doc_kit: ^0.0.8