From 9e529de76578c461598daa03dbb842aad9c81a48 Mon Sep 17 00:00:00 2001 From: Khoren Markosyan Date: Mon, 6 Jun 2022 14:54:49 +0400 Subject: [PATCH] version: 0.3.0 --- CHANGELOG.md | 7 +++++++ README.md | 31 ++++++++++++++++++++++--------- lib/flutter_zxing.dart | 4 ++-- lib/reader_widget.dart | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f13a874..517d22e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.3.0 + +* added processCameraImage function +* added pinch to zoom sopport +* added flash sopport +* added custom scanner overlay support + ## 0.2.0 * added 'readImagePath' function diff --git a/README.md b/README.md index 75565d2..bba4817 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,14 @@ A barcode and QR code scanner based on [ZXing C++](https://github.com/nu-book/zx | | DataBar Expanded | ## Features -- [x] Scan barcode from camera stream -- [x] Scan barcode from image path or url -- [x] Create barcode from text -- [ ] Read multiple barcodes from camera or gallery -- [ ] Return scanned barcode position and size +- Scan barcode from camera stream +- Scan barcode from image path or url +- Create barcode from text +- Flashlight and pinch to zoom support + +## Todo +- Read multiple barcodes from camera or gallery +- Return scanned barcode position and size ## Getting Started ### To read barcode: @@ -42,15 +45,25 @@ Widget build(BuildContext context) { ), ); -// Or use FlutterZxing to read barcode from camera image directly -cameraController?.startImageStream((img) async { - final bytes = await convertImage(img); - final result = FlutterZxing.readBarcode(bytes, Format.Any, img.width, img.height, 200, 200); +// Or use FlutterZxing +// To read barcode from camera image directly +cameraController?.startImageStream((image) async { + CodeResult result = await FlutterZxing.processCameraImage(image); if (result.isValidBool) { debugPrint(result.textString); } return null; }); + +// To read barcode from XFile, String or url +XFile xFile = XFile('Your image path'); +CodeResult? resultFromXFile = await FlutterZxing.readImagePath(xFile); + +String path = 'Your image path'; +CodeResult? resultFromPath = await FlutterZxing.readImagePathString(path); + +String url = 'Your image url'; +CodeResult? resultFromUrl = await FlutterZxing.readImageUrl(url); ``` ### To create barcode: diff --git a/lib/flutter_zxing.dart b/lib/flutter_zxing.dart index bcc710f..950f29c 100644 --- a/lib/flutter_zxing.dart +++ b/lib/flutter_zxing.dart @@ -129,8 +129,8 @@ class FlutterZxing { return result; } - static Future processCameraImage( - CameraImage image, int format, double cropPercent) async { + static Future processCameraImage(CameraImage image, + {int format = Format.Any, double cropPercent = 0.5}) async { var isolateData = IsolateData(image, format, cropPercent); CodeResult result = await _inference(isolateData); return result; diff --git a/lib/reader_widget.dart b/lib/reader_widget.dart index 40682f7..b182939 100644 --- a/lib/reader_widget.dart +++ b/lib/reader_widget.dart @@ -152,8 +152,8 @@ class _ReaderWidgetState extends State try { CodeResult result = await FlutterZxing.processCameraImage( image, - widget.codeFormat, - widget.cropPercent, + format: widget.codeFormat, + cropPercent: widget.cropPercent, ); if (result.isValidBool) { if (widget.beep) { diff --git a/pubspec.yaml b/pubspec.yaml index f83c84b..656bde6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_zxing description: A barcode scanner and generator natively in Flutter with Dart FFI based on ZXing. -version: 0.2.0 +version: 0.3.0 repository: https://github.com/khoren93/flutter_zxing environment: