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.

QR Code Scanner using Flutter, free download, free app, free source code, flutter, make an app, learn flutter, mobile app, android, ios

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<QRViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  var qrText = "";
  QRViewController controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          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:

				
					<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>
				
			

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

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.

Don’t forget to share this post!

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Article