๐Ÿ“Š Mofilo Barcode Verifier

Barcode validation using GS1 algorithms for format and checksum verification. Supports EAN-13, UPC-A, EAN-8, and UPC-E formats.

๐ŸŽฏ Quick Start

import 'package:mofilo_barcode_verifier/mofilo_barcode_verifier.dart';

void main() {
  final verifier = BarcodeVerifier();

  // Verify a single barcode
  final result = verifier.verify('5449000000996'); // EAN-13 example

  if (result.isValid) {
    print('โœ“ Valid ${result.barcodeType.name} barcode');
  } else {
    print('โœ— Invalid: ${result.message}');
    print('Errors: ${result.errors}');
  }
}

โœจ Features

  • ๐ŸŒ Format Support: EAN-13, UPC-A, EAN-8, UPC-E
  • โœ… Checksum Validation: Uses GS1 standard algorithms
  • โšก No External Dependencies: Pure Dart implementation, no network calls
  • ๐ŸŽฏ Format + Checksum: Validates both in one call
  • ๐Ÿ“ฆ Batch Verification: Process multiple barcodes at once
  • ๐Ÿงช Tested: Includes unit tests with example product barcodes

๐Ÿ”ฌ Validation Pipeline

1. Format Validation

  • Length verification (6, 8, 12, or 13 digits)
  • Numeric character validation
  • Barcode type detection

2. Checksum Validation

  • GS1 algorithm implementation
  • Designed to detect single-digit errors
  • Designed to detect most transposition errors

๐Ÿ“ฑ Usage Examples

Basic Validation

final verifier = BarcodeVerifier();
final result = verifier.verify('012000001970');

print(result.isValid);        // true
print(result.barcodeType);    // BarcodeType.upcA
print(result.message);        // "Valid UPC-A barcode"

Quick Boolean Check

if (verifier.isValid('5449000000996')) {
  print('Barcode is valid!');
}

Batch Verification

final barcodes = [
  '5449000000996',  // Coca-Cola
  '8000500037447',  // Nutella
  'invalid123',     // Invalid
];

final results = verifier.verifyBatch(barcodes);
for (final result in results) {
  print('${result.barcode}: ${result.isValid}');
}

Type Detection

final type = verifier.detectType('5449000000996');
print(type); // BarcodeType.ean13

๐ŸŒ Supported Barcode Types

Type Digits Common Usage Example
EAN-13 13 Worldwide 5449000000996
UPC-A 12 North America 012000001970
EAN-8 8 Small Packages 96385074
UPC-E 6 Compressed UPC 425261

โš ๏ธ Important Notes

What This Package Does

โœ… Validates barcode format and checksum โœ… Detects barcode type (EAN-13, UPC-A, etc.) โœ… Works offline with zero external dependencies

What This Package Does NOT Do

โŒ Does NOT identify product categories or types โŒ Does NOT query product databases โŒ Does NOT determine country of origin from prefix โŒ Does NOT verify if barcode actually exists

Why?

GS1 barcode prefixes identify the company/manufacturer, not the product type or category. This package performs syntactic validation only - it verifies that a barcode follows the correct format and has a valid checksum.

To determine if a barcode exists or get product information, you would need to:

  • Query a product database (OpenFoodFacts, GS1 GEPIR, etc.)
  • Maintain your own product database
  • Use additional verification layers

This package focuses on Layer 1 validation - the foundation for any barcode-based system. See PRODUCTION_VALIDATION_STRATEGY.md for multi-layer validation guidance.

๐Ÿ“Š Validation Results

class VerificationResult {
  final String barcode;           // Original barcode
  final bool isValid;             // Validation result
  final BarcodeType barcodeType;  // Detected type
  final VerificationStatus status; // Detailed status
  final String message;           // Human-readable message
  final List<String> errors;      // Validation errors
}

๐Ÿงช Testing

Tested with example product barcodes:

  • โœ… Coca-Cola (EAN-13)
  • โœ… Nutella (EAN-13)
  • โœ… Red Bull (EAN-13)
  • โœ… Campbell's Soup (UPC-A)
  • โœ… Spam (UPC-A)
  • โœ… Toblerone (EAN-13)
  • โœ… Haribo (EAN-13)

๐Ÿ“š Technical Standards

Implementation references:

Note: This package is not certified or endorsed by GS1.

๐Ÿค Contributing

Issues and pull requests are welcome! Please follow the existing code style and include tests for new features.

๐Ÿ“„ License

MIT License - see LICENSE file for details.

โš–๏ธ Disclaimer

This software is provided "as is" without warranty of any kind. The authors are not liable for any damages arising from its use. This package performs syntactic validation only and does not guarantee that barcodes are valid, issued by GS1, or correspond to actual products. Users should implement additional verification for production use.


Built by the Mofilo team ๐Ÿš€

mofilo_barcode_verifier

mofilo_barcode_verifier

Libraries

mofilo_barcode_verifier
A Flutter package for validating product barcodes.