obd_vin_decoder 0.0.5 copy "obd_vin_decoder: ^0.0.5" to clipboard
obd_vin_decoder: ^0.0.5 copied to clipboard

A pure Dart package for offline and online Vehicle Identification Number (VIN) decoding, supporting modern vehicles up to 2039

OBD VIN Decoder #

Copy everything inside the block below and paste it directly into your README.md file:Markdown# ๐Ÿš— OBD VIN Decoder

A lightweight, reliable pure Dart VIN decoding utility that uses offline ISO 3779 mathematical standards and an NHTSA API fallback enhanced with modern 30-year cycle year mapping, region detection, manufacturer identification, and a built-in mock VIN generator. Includes real-time data fetching for Make, Model, Engine, Plant Location, and Trim.

โœ… Features #

  • โœ… Pure Dart: Zero native code or permissions required.
  • โœ… Offline VIN decoding: Zero latency.
  • โœ… Modern Year Support: Accurately distinguishes 2001 vs 2031.
  • โœ… Manufacturer (WMI) identification
  • โœ… Region & Country detection
  • โœ… Online NHTSA API integration: For extended data.
  • โœ… Random Mock VIN Generator: Mathematically valid, perfect for testing.
  • โœ… Null-safe and strictly typed
  • โœ… Cross-platform: iOS, Android, Web, Mac, Windows, Linux.

๐Ÿš€ Getting Started #

1๏ธโƒฃ Add Dependencies #

In your pubspec.yaml:

dependencies:
  obd_vin_decoder: ^0.0.1
2๏ธโƒฃ Native Setup๐ŸŽ‰ NONE! Because this package is written in pure Dart, you do not need to modify your AndroidManifest.xml or iOS Info.plist. It works out of the box on every platform.3๏ธโƒฃ Import the PackageDartimport 'package:obd_vin_decoder/obd_vin_decoder.dart';
๐Ÿงฐ How to Useโœ… Step 1: Initialize and ValidateDartfinal vehicle = VIN(number: '1HGCM82633A004XXX');

if (!vehicle.isValid()) {
  print('Invalid 17-character VIN!');
  return;
}
โœ… Step 2: Offline Decoding (Zero Latency)Dartprint('Make: ${vehicle.getManufacturer()}'); // Honda
print('Year: ${vehicle.getYear()}');         // 2003
print('Region: ${vehicle.getRegion()}');     // North America
โœ… Step 3: Fetch Extended Data (NHTSA API)Dartfinal info = await vehicle.getExtendedInfo();

if (info != null) {
  print('Model: ${info.model}');
  print('Engine: ${info.engineCylinders} Cylinders');
  print('Displacement: ${info.displacementL} L');
  print('Plant: ${info.plantCity}, ${info.plantCountry}');
}
โœ… Step 4: Generate a Mock VIN (For Testing)DartString mockVin = VINGenerator.generate();
print('Generated VIN: $mockVin');
๐Ÿ“ฆ NHTSAVehicleInfo DTODartclass NHTSAVehicleInfo {
  final String? make;
  final String? model;
  final String? modelYear;
  final String? vehicleType;
  final String? engineCylinders;
  final String? displacementL;
  final String? trim;
  final String? plantCity;
  final String? plantCountry;
  
  // Includes a fromJson factory and toString override
}
๐Ÿ“ Built-in VIN GeneratorThe package includes a highly advanced mock VIN generator (VINGenerator.generate()). It doesn't just output random strings; it calculates correct WMI codes, valid check digits, and purposefully alternates the 7th character (Letters/Numbers) to guarantee the generated VIN perfectly aligns with the ISO 30-year cycle rules.๐Ÿ’ก Tipsโœ… Speed up your UI: Use the offline methods (getManufacturer(), getYear()) to update your UI instantly, then run getExtendedInfo() in the background to fill in the rest of the details once the API returns.๐ŸŽฏ NHTSA Limitations: The NHTSA database primarily focuses on vehicles manufactured for sale in North America. For JDM or purely European vehicles, rely on the offline decoder methods.๐Ÿง  Validation: Always call .isValid() before decoding to prevent processing incomplete barcodes or typed errors.๐Ÿ› TroubleshootingProblemSolutionisValid() returns falseEnsure the VIN is exactly 17 characters and does not contain the letters I, O, or Q.Year decodes incorrectlyEnsure the 7th character of the VIN is correct. The package uses this to determine if the car is pre-2010 or post-2010.API returns nullThe NHTSA server might be down, or the vehicle was not manufactured for the North American market. Fall back to offline methods.โœ… Example IntegrationDartimport 'package:obd_vin_decoder/obd_vin_decoder.dart';

void main() async {
  // 1. Generate a test VIN
  String mockVin = VINGenerator.generate();
  print('Testing with VIN: $mockVin');

  // 2. Initialize
  final vehicle = VIN(number: mockVin);

  if (vehicle.isValid()) {
    // 3. Instant Offline Data
    print('--- OFFLINE DATA ---');
    print('Make: ${vehicle.getManufacturer()}');
    print('Year: ${vehicle.getYear()}');
    
    // 4. Detailed Online Data
    print('--- ONLINE DATA ---');
    final info = await vehicle.getExtendedInfo();
    
    if (info != null) {
      print('Model: ${info.model}');
      print('Type: ${info.vehicleType}');
    } else {
      print('No extended data found in NHTSA database.');
    }
  }
}
๐Ÿ”ฎ Coming Soonโœ… European database fallback supportโŒ Specific brand decoders (e.g., decoding BMW option codes)โŒ VIN Barcode / QR Scanner UI widget๐Ÿค ContributingFeel free to fork the repo, submit PRs, or report issues. You can request:Additional offline WMI mappingsIntegrations with other regional transport APIs
## Installation

Add the package to your `pubspec.yaml`:

```yaml
dependencies:
  obd_vin_decoder: ^0.0.1
1
likes
0
points
96
downloads

Publisher

unverified uploader

Weekly Downloads

A pure Dart package for offline and online Vehicle Identification Number (VIN) decoding, supporting modern vehicles up to 2039

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on obd_vin_decoder