QR Code Scanner
QR Code Scanner using Flutter
QR codes are 3D barcodes that can be read by smartphones. They’re primarily used by the advertising and marketing industry. Companies can use QR codes to provide information to their customers via their fingertips. Customers can easily scan a QR code on the internet or on a product packaging and retrieve information.
The advantages of using QR codes are enormous: they increase your website’s accessibility and help you gain new customers. Therefore, developing a QR code scanner is highly recommended for any business that wants to succeed in today’s competitive marketplace.
Project Outline: QR Code Scanner
The QR code scanner works on both Android and iOS by naturally embedding the platform view within Flutter. Integrating Flutter is seamless, simpler than diving into a native Activity or a ViewController to perform a scan.
Get QR Code Scanner using Flutter
class _QRViewExampleState extends State {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = "";
QRViewController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Expanded(
flex: 5,
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
),
Expanded(
flex: 1,
child: Center(
child: Text('Scan result: $qrText'),
),
)
],
),
);
}
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
setState(() {
qrText = scanData;
});
});
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
}
iOS Integration: QR Code Scanner
To utilize this plugin, add the following to your Info.plist file:
io.flutter.embedded_views_preview
NSCameraUsageDescription
This app needs camera access to scan QR codes
SDK
Requires at least SDK 24 (Android 7.0).
TODOs
- iOS Native embedding is written to match what is supported in the framework as of the date of publication of this package. It needs to be improved as the framework support improves.
- In the future, options will be provided for default states.
- Finally, I welcome PRs to make it better :).
Requirements
- Download the latest version of Android Studio SDK
- Download and Install Flutter SDK
- Install the plugin Flutter and Dart for VS Code or Flutter in Android Studio
How To Run
- Check if the branch is the origin/developed.
- Proceed to run in terminal flutter packages get.
- If you don’t want to emulate the SDK on your computer, you need to connect your mobile phone.
- After which run with F5 if you use Visual studio code or run with the button play in Android Studio.