FLUTTER ECOSYSTEM

deadblit/barras

一个简单且可自定义的条形码扫描 Flutter 包,适用于 Android 和 iOS。它在 iOS 上使用 AVCaptureSession,在 Android 上使用 ZXing。

条形 项目封面
Stars
20
Forks
24
最近推送(UTC)
2024年6月4日
项目状态
未归档
deadblit GitHub avatar
GITHUB User

deadblit ↗

@spacerockdev Recife, Brazil
语言DartRubySwiftKotlinObjective-C

技术话题

此仓库发布的插件

使用的依赖

依赖清单 5 项

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

Barras

This document is also available in: English | Português


Barras is a simple and customizable barcode scanning Flutter package for Android and iOS. It uses AVCaptureSession in iOS and ZXing in Android.

Please bear in mind that Barras is experimental, in early development stage.

Getting Started

Requirements

Barras requires camera usage permission, on both iOS and Android. This must be implemented by you, considering any alternatives that you may be already using for user permission requests.

If you are not handling permissions yet, there are good plugins to do it, like permission_handler.

Besides that, Barras depends on the following:

  • Flutter 2.10.5 or higher
  • Android API 26 (Marshmallow) or newer
  • iOS 9.0 or newer
Import and use in your code

Add Barras dependency to the pubspec.yaml file:

dependencies:
  barras: ^0.2.1

Import it in your code:

import 'package:barras/barras.dart';

Simply call the scan method, and we are good to go:

// Open the barcode reading page. Returned data will be null if
// Cancel button is pressed, or if user navigates back
final data = await Barras.scan(context);

Default barcode capture page

You can also customize the appearance of the barcode capture page:

// Open the barcode reading page. Customize the appearance, changing the
// viewfinder color, size and blinking speed. Returned data will be null
// if Cancel button is pressed, or if user navigates back
final data = await Barras.scan(
  context,
  viewfinderHeight: 120,
  viewfinderWidth: 300,
  scrimColor: Color.fromRGBO(128, 0, 0, 0.5),
  borderColor: Colors.red,
  borderRadius: 24,
  borderStrokeWidth: 2,
  buttonColor: Colors.yellow,
  borderFlashDuration: 250,
  cancelButtonText: "取消",
  successBeep: false,
);

Customized barcode capture page

You can check a working example app in the example folder.