flutter_barcode_scanner_ohos 1.0.0 copy "flutter_barcode_scanner_ohos: ^1.0.0" to clipboard
flutter_barcode_scanner_ohos: ^1.0.0 copied to clipboard

a plugin for Flutter apps that adds barcode scanning support on Ohos.

flutter_barcode_scanner_ohos #

flutter_barcode_scanner_ohos is a plugin for Flutter apps that adds barcode scanning support on Ohos.

How to use ? #

To use on ohos, you will need to add the camera permission in module.json5.

"requestPermissions": [
      {
        "name": "ohos.permission.CAMERA",
        "reason": "$string:reason",
        "usedScene": {
          "abilities": [
            "EntryAbility"
          ],
          "when": "inuse"
        }
      }
    ]

After making the changes in Ohos add flutter_barcode_scanner to pubspec.yaml

dependencies:
  ...
  flutter_barcode_scanner: ^2.0.0

Usage #

  yaml
    dependencies:
      flutter_barcode_scanner: 2.0.0
      flutter_barcode_scanner_ohos: 1.0.0

One time scan #

  1. You need to import the package first.
import 'package:flutter_barcode_scanner_ohos/flutter_barcode_scanner.dart';
  1. Then use the scanBarcode method to access barcode scanning.
String barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
                                                    COLOR_CODE, 
                                                    CANCEL_BUTTON_TEXT, 
                                                    isShowFlashIcon, 
                                                    scanMode);

Here in scanBarcode,

COLOR_CODE is hex-color which is the color of line in barcode overlay you can pass color of your choice,

CANCEL_BUTTON_TEXT is a text of cancel button on screen you can pass text of your choice and language,

isShowFlashIcon is bool value used to show or hide the flash icon,

scanMode is a enum in which user can pass any of { QR, BARCODE, DEFAULT }, if nothing is passed it will consider a default value which will be QR. It shows the graphics overlay like for barcode and QR.

NOTE: Currently, scanMode is just to show the graphics overlay for barcode and QR. Any of this mode selected will scan both QR and barcode.

Continuous scan #

  • If you need to scan barcodes continuously without closing camera use FlutterBarcodeScanner.getBarcodeStreamReceiver params will be same like FlutterBarcodeScanner.scanBarcode e.g.
FlutterBarcodeScanner.getBarcodeStreamReceiver("#ff6666", "Cancel", false, ScanMode.other)
         .listen((barcode) { 
         /// barcode to be used
         });
0
likes
130
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

a plugin for Flutter apps that adds barcode scanning support on Ohos.

Repository

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_plugin_android_lifecycle, plugin_platform_interface

More

Packages that depend on flutter_barcode_scanner_ohos

Packages that implement flutter_barcode_scanner_ohos