Skip to content

Commit

Permalink
v1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Verbruik committed Aug 9, 2024
1 parent dc3ce8b commit 8e86435
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.11
- Improve MRZ reader with text and image callback

## 1.0.10
- Kotlin DSL for example app
- Bug fix : Fix Android supported version to 1.8
Expand Down
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# native_barcode_scanner
___# native_barcode_scanner

A fast flutter plugin to scan barcodes and QR codes using the device camera. This plugin also supports text and MRZ recognition from the camera.

Expand Down Expand Up @@ -46,7 +46,7 @@ Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
native_barcode_scanner: ^1.0.10
native_barcode_scanner: ^1.0.11
```
## Usage
Expand All @@ -61,13 +61,27 @@ Then, create a `BarcodeScannerWidget` in your widget tree where you want to show

```dart
@override
Widget build(BuildContext context) {
return BarcodeScannerWidget(
Widget build(BuildContext context) {
return BarcodeScannerWidget(
onBarcodeDetected: (barcode) {
print('Barcode detected: ${barcode.value} (format: ${barcode.format.name})');
}
);
}
```

Depending on what you want to scan, change the `scannerType` which is default to `ScannerType.barcode` and use the associated callback:

```dart
@override
Widget build(BuildContext context) {
return BarcodeScannerWidget(
scannerType: ScannerType.mrz,
onMrzDetected: (String mrz, Uint8List bytes) {
print('MRZ detected: $mrz');
}
);
}
```

If you need to manipulate the behaviour of the barcode scanning process, you may use the static methods of the `BarcodeScanner` class.
If you need to manipulate the behaviour of the barcode scanning process, you may use the static methods of the `BarcodeScanner` class.___
20 changes: 4 additions & 16 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyApp extends StatefulWidget {
State<MyApp> createState() => _MyAppState();
}

enum CameraActions { flipCamera, toggleFlashlight, stopScanner, startScanner, setOverlay, navigate, mrz, barcode, text }
enum CameraActions { flipCamera, toggleFlashlight, stopScanner, startScanner, setOverlay, navigate }

class _MyAppState extends State<MyApp> {
@override
Expand Down Expand Up @@ -58,8 +58,9 @@ class MyDemoApp extends StatefulWidget {
}

class _MyDemoAppState extends State<MyDemoApp> {

bool withOverlay = true;
ScannerType scannerType = ScannerType.mrz;
ScannerType scannerType = ScannerType.barcode;

@override
Widget build(BuildContext context) {
Expand All @@ -80,15 +81,6 @@ class _MyDemoAppState extends State<MyDemoApp> {
case CameraActions.startScanner:
BarcodeScanner.startScanner();
break;
case CameraActions.mrz:
setState(() => scannerType = ScannerType.mrz);
break;
case CameraActions.barcode:
setState(() => scannerType = ScannerType.barcode);
break;
case CameraActions.text:
setState(() => scannerType = ScannerType.text);
break;
case CameraActions.setOverlay:
setState(() => withOverlay = !withOverlay);
break;
Expand All @@ -106,10 +98,6 @@ class _MyDemoAppState extends State<MyDemoApp> {
value: CameraActions.stopScanner,
child: Text('Stop scanner'),
),
...List.generate(ScannerType.values.length, (index) => PopupMenuItem<CameraActions>(
value: ScannerType.values[index] == ScannerType.mrz ? CameraActions.mrz : ScannerType.values[index] == ScannerType.text ? CameraActions.text: CameraActions.barcode,
child: Text('Type ${ScannerType.values[index].name}'),
)),
const PopupMenuItem<CameraActions>(
value: CameraActions.flipCamera,
child: Text('Flip camera'),
Expand All @@ -131,7 +119,7 @@ class _MyDemoAppState extends State<MyDemoApp> {
]),
body: Builder(builder: (builderContext) {
Widget child = BarcodeScannerWidget(
scannerType: scannerType,
scannerType: ScannerType.mrz,
onBarcodeDetected: (barcode) async {
await showDialog(
context: builderContext,
Expand Down
2 changes: 1 addition & 1 deletion ios/native_barcode_scanner.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'native_barcode_scanner'
s.version = '1.0.10'
s.version = '1.0.11'
s.summary = 'Barcode scanner plugin'
s.description = <<-DESC
Barcode scanner plugin
Expand Down
2 changes: 1 addition & 1 deletion lib/barcode_scanner.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BarcodeScannerWidget extends StatefulWidget {
/// This function will be called when a bloc of text or a MRZ is detected.
final Function(String textResult)? onTextDetected;

final Function(String textResult, Uint8List image)? onMrzDetected;
final Function(String mrz, Uint8List image)? onMrzDetected;

final Function(dynamic error) onError;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: native_barcode_scanner
description: Fast barcode/QR scanner plugin using PlatformView and processing on native side
version: 1.0.10
version: 1.0.11
repository: https://github.com/freedelity/flutter_native_barcode_scanner

environment:
Expand Down

0 comments on commit 8e86435

Please sign in to comment.