diagnostic_trouble_codes 1.0.3
diagnostic_trouble_codes: ^1.0.3 copied to clipboard
A clean, asynchronous Flutter wrapper around the DTC Database created by Waleed Judah (Wal33D) enabling fast local lookups of OBD-II fault codes without APIs, internet access, or custom SQL logic.
๐ Diagnostic Trouble Codes (Flutter) #
A fully offline Diagnostic Trouble Code (DTC) database for Flutter.
This package provides a clean, asynchronous Flutter wrapper around the DTC Database created by Waleed Judah (Wal33D) โ enabling fast local lookups of OBD-II fault codes without APIs, internet access, or custom SQL logic.
The original database and definitions are maintained by Wal33D. ๐ฆ The
dtc_codes_v0.1.0.dbdatabase is already bundled inside this package. No manual download or setup is required.
๐ Original Repository: https://github.com/Wal33D/dtc-database
โจ What This Package Does #
Most diagnostic apps need to:
- Interpret OBD-II fault codes
- Provide descriptions instantly
- Work offline
- Avoid maintaining their own database logic
This package provides:
โ Offline SQLite DTC database โ Generic SAE J2012 coverage โ Manufacturer-specific definitions โ Zero CRUD required โ Built-in caching (LRU) โ Async Flutter-native API โ Asset-based database loading โ Production-safe singleton access
๐ฑ Platform Support #
| Platform | Status |
|---|---|
| Android | โ Supported |
| iOS | โ ๏ธ Untested |
| macOS | โ ๏ธ Untested |
| Windows | โ ๏ธ Untested |
| Linux | โ ๏ธ Untested |
| Web | โ Not Supported (SQLite required) |
๐ Database Overview #
Dataset included via the original project:
| Category | Count |
|---|---|
| Total Definitions | 18,805 |
| Unique DTC Codes | 12,128 |
| Generic Codes | 9,415 |
| Manufacturer Codes | 9,390 |
| Manufacturers | 33 |
| Powertrain (P) | 14,821 |
| Body (B) | 1,465 |
| Chassis (C) | 985 |
| Network (U) | 1,534 |
๐ Database Compatibility #
This package follows the release lifecycle of the original Wal33D DTC Database project.
| diagnostic_trouble_codes | Wal33D DTC Database |
|---|---|
| 1.0.x | >= 0.1.0 |
The bundled database snapshot corresponds to Wal33D DTC Database v0.1.0.
Future package updates will primarily occur when:
- The upstream database publishes a new release
- Dependencies require updates
- Wrapper code adapts to upstream structural changes
๐ Example Dashboard #
๐ง Why Use This Package? #
Typical implementations require:
โ Remote API calls โ Manual SQLite queries โ Custom schema handling โ Code normalization logic โ Manufacturer fallback logic
Diagnostic Trouble Codes provides:
- ๐ Instant local lookup
- ๐งฉ Simple Flutter integration
- ๐ง Correct fallback behavior (manufacturer โ generic)
- โก Cached repeated queries
- ๐ Offline reliability
๐ Getting Started #
- Installation #
dependencies:
diagnostic_trouble_codes: ^1.0.0
- Initialize Database #
final db = await DiagnosticTroubleCodeDatabase.instance;
Initialization automatically:
- Copies database from assets
- Stores it locally
- Opens SQLite connection
No setup required.
๐ Basic Usage #
Lookup a Code #
final diagnosticTroubleCode = await database.getDiagnosticTroubleCode('P0420');
print('${diagnosticTroubleCode?.code}: ${diagnosticTroubleCode?.description}');
Get Description Only #
final description = await database.getDescription('P0171');
print(description);
Manufacturer-Specific Lookup #
final fordSpecific = await database.getDescription(
'P1690',
manufacturer: 'FORD',
);
Automatically falls back to generic definitions if unavailable.
Search Codes #
final diagnosticTroubleCodes = await database.search('oxygen', limit: 10);
for (final diagnosticTroubleCode in diagnosticTroubleCodes) {
print('${diagnosticTroubleCode.code}: ${diagnosticTroubleCode.description}');
}
Batch Lookup #
final results = await database.batchLookup([
'P0171',
'P0300',
'B0001',
]);
print(results);
Filter by Type #
final powertrainCodes = await database.getByType('P', limit: 20);
Types:
| Code | Meaning |
|---|---|
| P | Powertrain |
| B | Body |
| C | Chassis |
| U | Network |
Manufacturer Codes #
final fordCodes = await database.getManufacturerCodes('FORD');
Database Statistics #
final statistics = await database.getStatistics();
print(statistics['total']);
print(statistics['type_P']);
Change Locale #
database.setLocale('en');
Changing locale automatically clears cache safely.
Close Database #
await database.close();
๐งฉ Data Model #
DiagnosticTroubleCode #
diagnosticTroubleCode.code
diagnosticTroubleCode.description
diagnosticTroubleCode.type
diagnosticTroubleCode.typeName
diagnosticTroubleCode.manufacturer
diagnosticTroubleCode.isGeneric
diagnosticTroubleCode.locale
Example:
P0420 - Catalyst System Efficiency Below Threshold
โก Performance Features #
Built-In LRU Cache #
Repeated lookups avoid database queries:
- Least Recently Used eviction
- Locale-aware cache keys
- Automatic invalidation
No configuration required.
๐ Architecture Overview #
Flutter App
โ
DiagnosticTroubleCodeDatabase
โ
sqflite (SQLite)
โ
dtc_codes_v0.1.0.db (Local Asset)
The database is:
- Fully local
- Read-only during runtime
- Optimized with indexes
๐ Relationship to Original Project #
This package wraps the database created by:
๐ค Waleed Judah (Wal33D) #
Original repository:
๐ https://github.com/Wal33D/dtc-database
The original project provides:
- Database generation
- Source datasets
- Python / Java / Android wrappers
This Flutter package provides:
โ Native Flutter integration โ Asset initialization โ Async Dart API โ Mobile-friendly caching
All diagnostic definitions belong to the original project.
๐งช Testing #
The package includes:
โ Schema validation tests โ Runtime behavior tests โ Cache validation tests โ SQLite FFI testing support
Run tests:
flutter test
โ What This Package Is Not #
This package does not:
- Communicate with vehicles
- Read OBD adapters
- Implement SAE J1979 protocols
- Replace diagnostic SDKs
It is strictly a:
๐ Diagnostic Trouble Code reference database
Perfect companion to OBD libraries such as Flutter OBD2.
๐ฏ Ideal Use Cases #
โ OBD-II mobile apps โ Diagnostic scanners โ Fleet management tools โ Mechanic reference apps โ Offline automotive tools โ Insurance claim validation systems
๐งญ Design Philosophy #
This package prioritizes:
- Simplicity over abstraction
- Offline reliability
- Correct diagnostic behavior
- Minimal developer friction
- API clarity
๐ License #
Package: Licensed under the Mozilla Public License 2.0.
Database & Definitions: MIT License โ ยฉ Waleed Judah (Wal33D)
See original repository for dataset licensing details.
๐ Credits #
Database Author: Waleed Judah (Wal33D) https://github.com/Wal33D
