barcode_flutter 1.0.2

  • Readme
  • Changelog
  • Installing
  • 94

Barcode Flutter is a Flutter library for simple and fast Barcode rendering via custom painter.

Features #

  • Supports code type: Code39, Code93, Code128, EAN13, EAN8, UPCA, UPCE
  • Supports render with or without text label
  • Supports adjusting the bar width
  • No internet connection required

Installing #

You can install the package by adding the following lines to your pubspec.yaml:

    barcode_flutter: ^1.0.2

After adding the dependency to your pubspec.yaml you can run: flutter packages get or update your packages using your IDE.

Getting started #

To start, import the dependency in your code:

import 'package:barcode_flutter/barcode_flutter.dart';

Next, to reander a Barcode (Code39 for example), you can use the following code:

new BarCodeImage(
  data: "1234ABCD",              // Code string. (required)
  codeType: BarCodeType.Code39,  // Code type (required)
  lineWidth: 2.0,                // width for a single black/white bar (default: 2.0)
  barHeight: 90.0,               // height for the entire widget (default: 100.0)
  hasText: true,                 // Render with text label or not (default: false)
  onError: (error) {             // Error handler
    print('error = $error');

NOTE: You can only tweak the lineWidth parameter to change the entire widget's width. But value less than 2.0 will sometimes make the barcode scaner more difficult to recognize result correctly. 2.0 is a safe value for all code types.

Error handling: You have to make sure the code strings provided are valid. If you are not sure about the data, maybe it comes from user input or something, then setup onError method, and put your error handling logic there. Sometimes the library will render parts of the barcode if the data is invalid, and if that happens, I can't guarantee that the result can be recognized by a barcode scaner.

Example #

See the example directory for a basic working example.


Has it been tested in production? Can I use it in production? #

Yep! I've test it both on Android and iOS devices. Feel free to test it with any barcode scanner.

How about the other barcode types ? #

I've only implemented some most commonly used barcode types. But feel free to send PR to include more barcode types.

License #

Barcode flutter is released under BSD license. See LICENSE for details.

1.0.2 #

  • Fix EAN8 code invalid checksum bug

1.0.1 #

  • Fix issue. Scanning problem when code128 contains character 'M'

1.0.0 #

  • Initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  barcode_flutter: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:barcode_flutter/barcode_flutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/barcode_flutter.dart.

Run flutter format to format lib/barcode_flutter.dart.

Format lib/src/barcode_enum.dart.

Run flutter format to format lib/src/barcode_enum.dart.

Format lib/src/barcode_img.dart.

Run flutter format to format lib/src/barcode_img.dart.

Format lib/src/barcode_painter.dart.

Run flutter format to format lib/src/barcode_painter.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and barcode_flutter.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

Update (-2 points)

1 image link is insecure (e.g., use https URLs instead.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 < 3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8