flutter_qr_scanner 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

Flutter QR Scanner #

pub package

Scans QR code and Barcode using Google's Mobile Vision API

Usage #

import 'package:flutter/material.dart';
import 'package:flutter_qr_scanner/qr_scanner_camera.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter QR/Bar Code Reader',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter QR/Bar Code Reader'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _qrInfo = 'Scan a QR/Bar code';
  bool _camState = false;

  _qrCallback(String code) {
    setState(() {
      _camState = false;
      _qrInfo = code;
    });
  }

  _scanCode() {
    setState(() {
      _camState = true;
    });
  }

  @override
  void initState() {
    super.initState();
    _scanCode();
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: _camState
          ? Center(
              child: SizedBox(
                height: 1000,
                width: 500,
                child: QRScannerCamera(
                  onError: (context, error) => Text(
                    error.toString(),
                    style: TextStyle(color: Colors.red),
                  ),
                  qrCodeCallback: (code) {
                    _qrCallback(code);
                  },
                ),
              ),
            )
          : Center(
              child: Text(_qrInfo),
            ),
    );
  }
}


The QrCodeCallback can do anything you'd like, and wil keep receiving QR/Bar codes until the camera is stopped.

There are also optional parameters to QRScannerCamera.

fit #

Takes as parameter the flutter BoxFit. Setting this to different values should get the preview image to fit in different ways, but only BoxFit = cover has been tested extensively.

notStartedBuilder #

A callback that must return a widget if defined. This should build whatever you want to show up while the camera is loading (which can take from milliseconds to seconds depending on the device).

child #

Widget that is shown on top of the QRScannerCamera. If you give it a specific size it may cause weird issues so try not to.

key #

Standard flutter key argument. Can be used to get QRScannerCameraState with a GlobalKey.

offscreenBuilder #

A callback that must return a widget if defined. This should build whatever you want to show up when the camera view is 'offscreen'. i.e. when the app is paused. May or may not show up in preview of app.

onError #

Callback for if there's an error.

'formats' #

A list of supported formats, all by default. If you use all, you shouldn't define any others.

These are the supported types:

  ALL_FORMATS,
  AZTEC,
  CODE_128,
  CODE_39,
  CODE_93,
  CODABAR,
  DATA_MATRIX,
  EAN_13,
  EAN_8,
  ITF,
  PDF417,
  QR_CODE,
  UPC_A,
  UPC_E

Push and Pop #

If you push a new widget on top of a the current page using the navigator, the camera doesn't necessarily know about it.

Contributions #

Any kind of contribution will be appreciated.

[0.1.5] - September 23, 2019

  • Fixed bugs for reload camera

[0.1.4] - September 23, 2019

  • Fixed bugs

[0.1.3] - September 23, 2019

  • Fixed bugs

[0.1.2] - September 23, 2019

  • Fixed native_device_orientation issue

[0.1.1] - September 23, 2019

  • Fixed reload camera issue

[0.1.0] - September 19, 2019

  • DART 2 COMPATIBLE

[0.0.9] - September 19, 2019

  • Fixed some bugs

[0.0.8] - September 19, 2019

  • updated dart sdk version 2.0.0-dev.0.0

[0.0.7] - September 19, 2019

  • updated documentation

[0.0.6] - September 19, 2019

  • updated documentation

[0.0.5] - September 19, 2019

  • Fixed bugs & updated documentation

[0.0.4] - September 19, 2019

  • Fixed bugs

[0.0.3] - September 18, 2019

  • Fixed bug

[0.0.2] - September 18, 2019

  • Updated documentation

[0.0.1] - September 18, 2019

  • Flutter QR Reader initial release

example/README.md

flutter_qr_scanner_example #

Demonstrates how to use the flutter_qr_scanner plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_qr_scanner: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_qr_scanner/flutter_qr_scanner.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
74
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
87
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_qr_scanner.dart.

Run flutter format to format lib/flutter_qr_scanner.dart.

Format lib/qr_scanner_camera.dart.

Run flutter format to format lib/qr_scanner_camera.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.0.0 <3.0.0
flutter 0.0.0
native_device_orientation ^0.2.0 0.2.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8