Barcode Cleaner

A Flutter package for cleaning and formatting barcodes with various options.

Features

  • Remove leading zeros
  • Limit barcode length
  • Clean barcodes with various options:
    • Only numbers
    • Alphanumeric and ASCII characters
    • Symbols and ASCII characters
    • Custom cleaning options for different character sets

Installation

Add the following to your pubspec.yaml file:

dependencies:
  barcode_cleaner: <LATEST_VERSION>

Usage

import 'package:barcode_cleaner/barcode_cleaner.dart';

void main() {
  final barcodeCleaner = BarcodeCleaner();
  
  // Remove leading zeros
  final cleanedBarcode = barcodeCleaner.removeStartZero('00012345');
  print(cleanedBarcode); // '12345'
  
  // Limit barcode length
  final limitedBarcode = barcodeCleaner.removeIncreasedLetter('123456789', 5);
  print(limitedBarcode); // '12345'
  
  // Clean barcode with basic options
  final basicCleaned = barcodeCleaner.clean(
    barcode: 'ABC123!@#',
    cleanBarCodeOption: CleanBarCodeOption.onlyNumbers,
  );
  print(basicCleaned); // '123'
  
  // Clean barcode with custom options
  final customCleaned = barcodeCleaner.customClean(
    barcode: 'ABC123!@#',
    customCleanOption: CustomCleanOption.enCharSmallAndBigPlusNumbers,
  );
  print(customCleaned); // 'ABC123'
}

Available Cleaning Options

Basic Cleaning Options

  • none: No cleaning
  • onlyNumbers: Keep only numbers
  • alphaNumericAndAsciiCharOnly: Keep alphanumeric and ASCII characters
  • onlySymbolsAndAsciiChar: Keep symbols and ASCII characters

Custom Cleaning Options

  • onlyNumbers: Keep only numbers
  • enCharSmallAndBig: Keep English characters (both cases)
  • enCharSmallAndBigPlusNumbers: Keep English characters and numbers
  • enCharBig: Keep only uppercase English characters
  • enCharBigPlusNumbers: Keep uppercase English characters and numbers
  • enCharSmall: Keep only lowercase English characters
  • enCharSmallPlusNumbers: Keep lowercase English characters and numbers
  • arChar: Keep only Arabic characters
  • arCharPlusNumbers: Keep Arabic characters and numbers
  • arCharAndEnCharBigAndSmall: Keep Arabic and English characters
  • arCharAndEnCharBigAndSmallPlusNumbers: Keep Arabic, English characters, and numbers

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Libraries

barcode_cleaner
A Flutter package for cleaning and formatting barcodes with various options.
clean_options/clean_barcode_option
clean_options/custom_clean_option