FLUTTER ECOSYSTEM

PiotrFLEURY/camcode

一個 Flutter 網路攝影機條碼掃描程式庫

camcode 專案封面
Stars
11
Forks
11
最近推送(UTC)
2023年9月9日
專案狀態
未封存
Piotr FLEURY GitHub avatar
GITHUB User

Piotr FLEURY ↗

XPEHOFrance
語言DartRubyHTMLKotlinSwiftJavaScriptObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 6 項
  • flutter{"sdk":"flutter"}
  • flutter_web_plugins{"sdk":"flutter"}
  • js^0.6.2
  • flutter_test開發依賴{"sdk":"flutter"}
  • every_test開發依賴^1.0.0
  • pedantic開發依賴^1.9.0

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

camcode

A camera barcode scan library for Flutter Web

Web build status

Getting Started

Add a javascript file for barcode scan

function detectBarcode(dataUrl, callback) {

    // call here your favorite javascript barcode scan library
    // input must be an image dataUrl
    // output must be a single String

    // don't forget to trigger the call back in order to get the result
    callback(barcode);
}

Import javascript files into your index.html

<script src="LINK_TO_MY_AWESOME_JAVASCRIPT_BARCODE_SCAN_LIB"></script>
<script src="js/barcode.js"></script> // the javascript file with the detectBarcode function

Use it

import 'package:camcode/cam_code_scanner.dart';

showDialog(
    context: context,
    builder: (context) => CamCodeScanner(
    width: MediaQuery.of(context).size.width,
    height: MediaQuery.of(context).size.height,
    refreshDelayMillis: 200,
    onBarcodeResult: (barcode) {
        // do whatever you want
    },
    minimalResultCount: 2,
    ),
);

More options

Manually release resources

Sometimes, depending on your camcode usage, you may need to release resources manually.

1- To do so, create first a controller for the scanner

// Create a controller to send instructions to scanner
  final CamCodeScannerController _controller = CamCodeScannerController();

2- Then, add it to the CamCodeScanner

CamCodeScanner(
    width: ...,
    height: ...,
    refreshDelayMillis: ...,
    onBarcodeResult: (barcode) {
        ...
    },
    controller: _controller,
),

3- And finally, just call releaseResources() method when required

ElevatedButton(
    onPressed: () {
        _controller.releaseResources();
    },
    child: Text('Release resources'),
),

Calling this method will close the camera and stop the scanner process