搜索插件、代码仓与 APP 分类

插件详情v1.1.2

barcode_flutter

Barcode flutter 是一个 Flutter 库,通过自定义绘制器实现简单快速的条形码渲染。

近 30 天下载
138
喜欢数
22
Pub 分数
35

安装插件

flutter pub add barcode_flutter

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Barcode Flutter 是一个轻量级的 Flutter 库,专为使用自定义绘制器高效渲染条形码而设计。它使开发者能够在其 Flutter 应用中直接生成条形码图像,设置简单。该库支持多种条形码格式,并可无缝集成到 UI 组件中。该库以简洁和高性能为目标,非常适合需要即时生成条形码的应用场景,例如票务、库存跟踪或产品标签。该软件包是开源的,由 Bigship 维护。

适合场景

  • 在应用程序中生成动态条形码
  • 将条形码集成到UI组件中
  • 创建产品标签
  • 跟踪库存项目
  • 显示票证或收据
  • 启用快速扫描就绪代码

主要特点

  • 基于自定义绘制者的渲染
  • 支持多种条形码格式
  • 轻量且快速的性能
  • 简单 API 集成
  • 开源且持续维护
  • 无外部依赖

适合对象

  • 需要条形码视觉效果的移动应用开发者
  • 需要实时条形码生成的应用程序
  • 专注于效率和最小开销的项目
  • 开发库存或票务系统的开发者
  • Flutter 初学者探索自定义绘图

使用建议

  • 仅限视觉渲染(不支持扫描)
  • 无内置条形码解码
  • 需要手动处理条形码数据
  • 不适合复杂的条形码逻辑
  • 依赖于正确的输入格式规范

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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

screenshot


Update Notes

1.1.2

  • Add Codabar support
  • Fix wrong pattern for value 102 of Code128 (#20)

1.1.0

  • Add ITF support
  • Add BarCodeParams class for future expandability

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

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:

dependencies:
    barcode_flutter: ^1.1.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:

BarCodeImage(
  params: Code39BarCodeParams(
    "1234ABCD",
    lineWidth: 2.0,                // width for a single black/white bar (default: 2.0)
    barHeight: 90.0,               // height for the entire widget (default: 100.0)
    withText: 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.

FAQ

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.

所属分类

源码仓库

使用此插件的项目