搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案