mofilo_barcode_verifier 1.0.1 copy "mofilo_barcode_verifier: ^1.0.1" to clipboard
mofilo_barcode_verifier: ^1.0.1 copied to clipboard

Barcode validation with GS1 checksum verification. Supports EAN-13, UPC-A, EAN-8, and UPC-E formats.

Mofilo Barcode Verifier #

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

pub package License: MIT


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}');
  }
}

That's it! The verifier handles format detection and checksum validation automatically.


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
  • ๐Ÿ”’ Privacy-Friendly - All processing happens locally
  • ๐Ÿงช Well-Tested - Includes unit tests with example product barcodes

Installation #

Add to your pubspec.yaml:

dependencies:
  mofilo_barcode_verifier: ^1.0.1

Then run:

dart pub get

Or for Flutter projects:

flutter pub get

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

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

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
  • Performs syntactic validation using GS1 standards

โš ๏ธ 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.


Result Object #

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.


Use Cases #

Companies Using This #

Great for apps that need barcode validation for:

  • Point-of-sale systems (validate scanned barcodes)
  • Inventory management (verify product codes)
  • E-commerce platforms (validate product identifiers)
  • Food & nutrition apps (check product barcodes)
  • Retail applications (input validation)

Contributing #

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


MIT License - Copyright (c) 2025 Mofilo

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. See LICENSE for full terms.


Built by the Mofilo team ๐Ÿš€

0
likes
155
points
2
downloads

Publisher

verified publishermofilo.app

Weekly Downloads

Barcode validation with GS1 checksum verification. Supports EAN-13, UPC-A, EAN-8, and UPC-E formats.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on mofilo_barcode_verifier