flutter_barcode_scanner_plus
一个支持 Android 和 iOS 上条形码扫描的插件。支持条形码、二维码等。
SarangthemAmarjit/flutter_barcode_scanner_plus open-source repository details.
{"sdk":"flutter"}^2.0.1^1.11.0^1.16.8以下为英文项目原文快照,最新内容请访问 GitHub。
A plugin for Flutter apps that adds barcode scanning support on both Android and iOS.
Demo gif
Just clone or download the repository, open the project in Android Studio/ VS Code, open pubspec.yaml and click on Packages get.
Connect device and hit run.
To run on iPhone you need to run from Xcode first time and just make pod install in example/ios then run from Xcode.
Follow the steps for Android and iOS
PLEASE FOLLOW iOS STEPS CAREFULLY
:zap: Don't worry, you don't need to do anything.
Deployment target : 12
/ios project in Xcode and set minimum deployment target to 12
and set Swift version to 5./ios in flutter project.You have done with basic configuration now proceed to section How to use.
/ios in flutter project./ios folder from project and replace with existing /ios./iosNote: If you did any changes in ios part before, you might need to make these configuration again
To use on iOS, you will need to add the camera usage description.
To do that open the Xcode and add camera usage description in Info.plist.
<key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string>
After making the changes in Android ans iOS add flutter_barcode_scanner to pubspec.yaml
dependencies:
...
flutter_barcode_scanner_plus: ^3.0.15
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
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.
FlutterBarcodeScanner.getBarcodeStreamReceiver
params will be same like FlutterBarcodeScanner.scanBarcode
e.g.FlutterBarcodeScanner.getBarcodeStreamReceiver("#ff6666", "Cancel", false, ScanMode.DEFAULT)
.listen((barcode) {
/// barcode to be used
});
would :heart: to see any contribution, give :star: if you like
E-mail: sarangthemamarjit123@gmail.com