From 87c3343633184cf409f55e4a7fa74117b27a2b43 Mon Sep 17 00:00:00 2001 From: Khoren Markosyan Date: Sat, 20 Aug 2022 17:59:54 +0400 Subject: [PATCH] updated pubs and readme --- README.md | 24 +++++++++++++++--------- example/pubspec.lock | 2 +- lib/src/logic/barcode_encoder.dart | 14 +++++++------- lib/src/ui/writer_widget.dart | 10 ++++++++-- pubspec.yaml | 2 +- zxscanner/pubspec.lock | 16 ++++++++-------- zxscanner/pubspec.yaml | 2 +- 7 files changed, 41 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index d304e74..ae29476 100644 --- a/README.md +++ b/README.md @@ -56,27 +56,27 @@ Widget build(BuildContext context) { ), ); -// Or use FlutterZxing +// Or use flutter_zxing plugin methods // To read barcode from camera image directly -await FlutterZxing.startCameraProcessing(); // Call this in initState +await startCameraProcessing(); // Call this in initState cameraController?.startImageStream((image) async { - CodeResult result = await FlutterZxing.processCameraImage(image); + CodeResult result = await processCameraImage(image); if (result.isValidBool) { debugPrint(result.textString); } return null; }); -FlutterZxing.stopCameraProcessing(); // Call this in dispose +stopCameraProcessing(); // Call this in dispose // To read barcode from XFile, String or url XFile xFile = XFile('Your image path'); -CodeResult? resultFromXFile = await FlutterZxing.readImagePath(xFile); +CodeResult? resultFromXFile = await readImagePath(xFile); String path = 'Your image path'; -CodeResult? resultFromPath = await FlutterZxing.readImagePathString(path); +CodeResult? resultFromPath = await readImagePathString(path); String url = 'Your image url'; -CodeResult? resultFromUrl = await FlutterZxing.readImageUrl(url); +CodeResult? resultFromUrl = await readImageUrl(url); ``` ### To create barcode: @@ -101,8 +101,14 @@ Widget build(BuildContext context) { ); // Or use FlutterZxing to create barcode directly -final text = 'Text to encode'; -final result = FlutterZxing.encodeBarcode(text, 300, 300, Format.QRCode, 10, 0); +final result = encodeBarcode( + 'Text to encode', + format: Format.QRCode, + width: 300, + height: 300, + margin: 10, + eccLevel: 0, +); if (result.isValidBool) { final img = imglib.Image.fromBytes(width, height, result.bytes); final encodedBytes = Uint8List.fromList(imglib.encodeJpg(img)); diff --git a/example/pubspec.lock b/example/pubspec.lock index f2f1246..60ba770 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -42,7 +42,7 @@ packages: name: camera_avfoundation url: "https://pub.dartlang.org" source: hosted - version: "0.9.8+3" + version: "0.9.8+4" camera_platform_interface: dependency: transitive description: diff --git a/lib/src/logic/barcode_encoder.dart b/lib/src/logic/barcode_encoder.dart index 5f1d677..60cedd4 100644 --- a/lib/src/logic/barcode_encoder.dart +++ b/lib/src/logic/barcode_encoder.dart @@ -2,13 +2,13 @@ part of 'zxing.dart'; // Encode a string into a barcode EncodeResult encodeBarcode( - String contents, - int width, - int height, - int format, - int margin, - int eccLevel, -) { + String contents, { + int format = Format.QRCode, + int width = 300, + int height = 300, + int margin = 0, + int eccLevel = 0, +}) { return bindings.encodeBarcode( contents.toNativeUtf8().cast(), width, diff --git a/lib/src/ui/writer_widget.dart b/lib/src/ui/writer_widget.dart index ef0f347..a6f7fa5 100644 --- a/lib/src/ui/writer_widget.dart +++ b/lib/src/ui/writer_widget.dart @@ -187,8 +187,14 @@ class _WriterWidgetState extends State final int height = int.parse(_heightController.value.text); final int margin = int.parse(_marginController.value.text); final int ecc = int.parse(_eccController.value.text); - final EncodeResult result = - encodeBarcode(text, width, height, _codeFormat, margin, ecc); + final EncodeResult result = encodeBarcode( + text, + format: _codeFormat, + width: width, + height: height, + margin: margin, + eccLevel: ecc, + ); String? error; if (result.isValidBool) { try { diff --git a/pubspec.yaml b/pubspec.yaml index 08658ea..4fa3f53 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,7 +38,7 @@ ffigen: - "ios/Classes/src/native_zxing.h" functions: exclude: - - resultToCodeResult + - 'resultToCodeResult' # flutter pub publish --dry-run \ No newline at end of file diff --git a/zxscanner/pubspec.lock b/zxscanner/pubspec.lock index 61918bb..cc3bac1 100644 --- a/zxscanner/pubspec.lock +++ b/zxscanner/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "45.0.0" + version: "46.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.5.0" + version: "4.6.0" archive: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.4.0" + version: "8.4.1" camera: dependency: transitive description: @@ -119,7 +119,7 @@ packages: name: camera_avfoundation url: "https://pub.dartlang.org" source: hosted - version: "0.9.8+3" + version: "0.9.8+4" camera_platform_interface: dependency: transitive description: @@ -238,7 +238,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.1.4" fixnum: dependency: transitive description: @@ -391,7 +391,7 @@ packages: name: icons_launcher url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" image: dependency: "direct main" description: @@ -559,7 +559,7 @@ packages: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.17" + version: "2.0.19" path_provider_ios: dependency: transitive description: @@ -643,7 +643,7 @@ packages: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" quiver: dependency: transitive description: diff --git a/zxscanner/pubspec.yaml b/zxscanner/pubspec.yaml index 6b10399..4cd9186 100644 --- a/zxscanner/pubspec.yaml +++ b/zxscanner/pubspec.yaml @@ -43,7 +43,7 @@ dev_dependencies: flutter_test: sdk: flutter hive_generator: - icons_launcher: ^2.0.3 # flutter pub run icons_launcher:create + icons_launcher: ^2.0.4 # flutter pub run icons_launcher:create # integration_test: # sdk: flutter mobx_codegen: