mofilo_barcode_verifier 1.0.1
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.
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:
- GS1 General Specifications
- EAN/UPC Barcodes
- ISO/IEC 15420 (EAN/UPC)
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.
License & Legal #
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 ๐