in

A Fast QR Reader widget for Flutter For both Android and iOS

Fast QR Reader View Plugin

With the introduction of better and faster technology, people are now using their devices more than ever. It’s all about accessing everything in a snap and getting the information across from one person to another or from a business to a consumer. One of the trending widgets is the QR code. 
With the development of the value of QR codes, we will discuss a fast QR Reader widget for Flutter for both Android and iOS that allows access to the device’s cameras to scan multiple types of codes (QR, PDF417, CODE39, etc). heavily based on the camera.

qr reader
example

Red box is a Flutter animation (removable). Low FPS due to GIF

Features:

SSome of its outstanding features.

  • Display live camera preview in a widget.
  • Uses native AVFoundation code detection in iOS
  • Uses ML Kit in Android

Installation

First, add fast_qr_reader_view as a dependency in your pubspec.yaml file.

iOS

Add a row to the ios/Runner/Info.plist with the key Privacy - Camera Usage Description and a usage description.

Or in text format add the key:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>

Android

Add Firebase to your project following this step (only that step, not the entire guide).

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

Example

Here is a small example flutter app displaying a full-screen camera preview.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:fast_qr_reader_view/fast_qr_reader_view.dart';

List<CameraDescription> cameras;

Future<Null> main() async {
  cameras = await availableCameras();
  runApp(new CameraApp());
}

class CameraApp extends StatefulWidget {
  @override
  _CameraAppState createState() => new _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
  QRReaderController controller;

  @override
  void initState() {
    super.initState();
    controller = new QRReaderController(cameras[0], ResolutionPreset.medium, [CodeFormat.qr], (dynamic value){
        print(value); // the result!
    // ... do something
    // wait 3 seconds then start scanning again.
    new Future.delayed(const Duration(seconds: 3), controller.startScanning);
    });
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
      controller.startScanning();
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    if (!controller.value.isInitialized) {
      return new Container();
    }
    return new AspectRatio(
        aspectRatio:
        controller.value.aspectRatio,
        child: new QRReaderPreview(controller));
  }
}

For a more elaborate usage example see here.

GitHub

https://github.com/facundomedica/fast_qr_reader_view

Written by James

A Flutter plugin for reading QR Codes with the camera

Pretty QR code with round edges