mofilo_barcode_verifier 1.0.2 copy "mofilo_barcode_verifier: ^1.0.2" to clipboard
mofilo_barcode_verifier: ^1.0.2 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 - 116+ unit tests with real-world barcodes

Installation #

Add to your pubspec.yaml:

dependencies:
  mofilo_barcode_verifier: ^1.0.2

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: What This Package Does and Does NOT Do #

โœ… What This Package Does #

  • Validates barcode format (correct length, numeric characters)
  • Validates checksum using the GS1 Modulo-10 algorithm
  • Detects barcode type (EAN-13, UPC-A, EAN-8, UPC-E)
  • Works offline with zero external dependencies

โš ๏ธ What This Package Does NOT Do #

  • Does NOT verify if a barcode actually exists โ€” a made-up barcode with a valid checksum (e.g., 1234567890128) will pass
  • Does NOT identify whether a product is food, cosmetics, or any other category
  • Does NOT query any product database
  • Does NOT determine country of origin from GS1 prefix
  • Does NOT detect counterfeit barcodes

Why does this matter? #

A barcode with a valid checksum does not mean it corresponds to a real product. Roughly 1 in 10 random 13-digit numbers will have a mathematically valid checksum. This package performs syntactic validation only โ€” it checks structure and math, not existence.

To verify a barcode is real or get product information, you need a database lookup:

This package is Layer 1 (syntactic validation) in a multi-layer system. See PRODUCTION_VALIDATION_STRATEGY.md for production 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 #

116+ unit tests covering real-world barcodes, invalid formats, checksum failures, and edge cases. Example products tested:

  • โœ… EAN-13: Coca-Cola, Nutella, Red Bull, Toblerone, Haribo
  • โœ… UPC-A: Campbell's Soup, Spam
  • โœ… EAN-8 and UPC-E formats
  • โœ… Invalid checksums, non-numeric input, wrong lengths

Technical Standards #

Implementation references:

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

Industry Note: GS1 Sunrise 2027 #

The barcode industry is transitioning from 1D barcodes (EAN/UPC) to 2D barcodes (QR codes with GS1 Digital Link) by end of 2027. This package currently supports 1D formats only. As of 2025-2026, retailers are in a dual-labeling period where both 1D and 2D barcodes coexist. Learn more at GS1 Sunrise 2027.


Use Cases #

Great for apps that need barcode format validation as a first step:

  • Point-of-sale systems (reject damaged or mistyped scans)
  • Inventory management (validate product codes before database lookup)
  • E-commerce platforms (input validation for product identifiers)
  • Retail and logistics applications (filter invalid barcodes early)

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
160
points
142
downloads

Documentation

API reference

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)

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on mofilo_barcode_verifier