The QRCode & Barcode Scanner plugin is designed to manage QR and Barcode scanning from external devices, offering a streamlined API for integration in Android applications.
Important: This package currently supports Android only.
QrcodeBarcodeScanner
class to easily handle scan events.Add the following dependency in your pubspec.yaml
file:
flutter pub add qrcode_barcode_scanner
Here is a simple example of how to use the QrcodeBarcodeScanner
:
import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner.dart';
class MyScannerApp extends StatefulWidget {
@override
_MyScannerAppState createState() => _MyScannerAppState();
}
class _MyScannerAppState extends State<MyScannerApp> {
String? _scanValue;
@override
void initState() {
super.initState();
QrcodeBarcodeScanner(
onScannedCallback: (String value) {
setState(() {
_scanValue = value;
});
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("QR & Barcode Scanner")),
body: Center(
child: Text(_scanValue ?? "Waiting for scan..."),
),
);
}
}
QrcodeBarcodeScanner
The QrcodeBarcodeScanner
class is the core component of this plugin. It allows you to configure
and manage barcode and QR code scanning events.
Constructor:
QrcodeBarcodeScanner({
required ScannedCallback onScannedCallback,
});
Properties:
onScannedCallback
: A callback function that is triggered when a scan is successful. Receives the
scanned value as a string.This plugin has been tested with the following devices:
For more detailed documentation and advanced use cases, check out the Wiki.
Check out the Changelog for details on recent updates.
Want to contribute? Check out the Contribution Guide to get started!
This project is licensed under the MIT License. See the LICENSE file for details.