code_scan

Creator: coderz1093

Last updated:

Add to Cart

Description:

code scan

Code Scanner #
A flexible code scanner for QR codes, barcodes and many others. Using Google's ML Kit. Use it as a Widget with a camera or use the methods provided, with a camera controller.
Features #

Scan Linear and 2D formats: QR Code, Barcode, ...
Widget with integrated camera
Listen for callbacks with every code scanned
Choose which formats to scan
Overlay the camera preview with a custom view
Camera lifecycle

Scannable Formats #

Aztec
Codabar
Code 39
Code 93
Code 128
Data Matrix
EAN-8
EAN-13
ITF
PDF417
QR Code
UPC-A
UPC-E

Getting started #
Install it using pub:
flutter pub add code_scan
copied to clipboard
And import the package:
import 'package:code_scan/code_scan.dart';
copied to clipboard
Usage #
CodeScanner(
onScan: (code, details, controller) => setState(() => this.code = code),
onScanAll: (codes, controller) => print('Codes: ' + codes.map((code) => code.rawValue).toString()),
formats: [ BarcodeFormat.qrCode ],
once: true,
)
copied to clipboard
Add callbacks for events:
CodeScanner(
onScan: (code, details, controller) => ...,
onScanAll: (codes, controller) => ...,
onCreated: (controller) => ...,
)
copied to clipboard
Set loading and overlay widgets, although you can use the default overlay:
CodeScanner(
loading: Center(child: CircularProgressIndicator()),
overlay: Center(child: Text('Scanning...')),
)
copied to clipboard
Choose how the widget should react:
CodeScanner(
direction: CameraLensDirection.back,
resolution: ResolutionPreset.medium,
formats: const [ BarcodeFormat.all ],
scanInterval: const Duration(seconds: 1),
aspectRatio: 480 / 720, // height / width
once: false,
)
copied to clipboard
The default behavior of the widget is to fill the screen or parent widget, but you can choose the aspect ratio.
You can use the camera view with your camera controller, without having the scanning widget:
final cameraController = CameraController();

CodeScannerCameraView(
controller: cameraController,
)
copied to clipboard
Caution #
If you use your camera controller, it's recommended that you be responsible to control camera resources.
Manage it yourself using the lifecycle or make sure it's already being managed by some other widget.
Methods provided #
Create a camera listener and plug it with any camera controller, to scan for codes:
final cameraController = CameraController();

final listener = CodeScannerCameraListener(
cameraController,

formats: const [ BarcodeFormat.all ],
interval: const Duration(milliseconds: 500),
once: false,

onScan: (code, details, controller) => ...,
onScanAll: (codes, controller) => ...,
);
copied to clipboard
Stop the listener whenever you want:
listener.stop();
copied to clipboard
GitHub #
The package code is available on Github: Flutter - CodeScanner

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.