qr_mobile_vision 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

QR Mobile Vision

Reading QR codes and other barcodes using Google's Mobile Vision API.

This plugin uses Android & iOS native APIs for reading images from the device's camera. It then pipes these images both to the Mobile Vision API which detects barcodes/qrcodes etc, outputs a preview image to be shown on a flutter texture.

The plugin includes a widget which performs all needed transformations on the camera output to show within the defined area.

Usage

See the example for how to use this plugin; it is the best resource available as it shows the plugin in use. However, these are the steps you need to take to use this plugin.

First, figure out the area that you want the camera preview to be shown in. This is important as the preview needs to have a constrained size or it won't be able to build. This is required due to the complex nature of the transforms needed to get the camera preview to show correctly on both iOS and Android, while still working with the screen rotated etc.

It may be possible to get the camera preview to work without putting it in a SizedBox or Container, but the recommended way is to put it in a SizedBox or Container.

You then need to include the package and instantiate the camera.

import 'package:qr_mobile_vision/qr_camera.dart';

...

new SizedBox(
  width: 300.0,
  height: 600.0,
  child: new QrCamera(
    qrCodeCallback: (code) {
      ...
    },
  ),
)

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

There are also 2 optional parameters to QrCamera. The first is fit, which takes as parameter the flutter BoxFit. Setting this to differnet values should get the preview image to fit in different ways, but only BoxFit = cover has been tested.

The other is notStartedBuilder, which is 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).

Contributions

Anyone wanting to contribute to this project is very welcome to! I'll take a look at PR's as soon as I can, and any bug reports are appreciated. I've only a few devices on which to test this so feedback about other devices is appreciated as well.

This has been tested on:

  • Nexus 5x
  • Nexus 4
  • Alcatel Idol X Plus
  • Essential Phone

[0.0.1] - June 5, 2018

  • Initial release that supports scanning all types of barcodes that the QR Mobile Vision library supports.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:qr_mobile_vision/qr_camera.dart';

void main() {
  debugPaintSizeEnabled = false;
  runApp(new HomePage());
}

class HomePage extends StatefulWidget {
  @override
  HomeState createState() => new HomeState();
}

class HomeState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(home: new MyApp());
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String qr;
  bool camState = false;

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

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Plugin example app'),
      ),
      body: new Center(
        child: new Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Expanded(
                child: camState
                    ? new Center(
                      child: new SizedBox(
                        width: 300.0,
                        height: 600.0,
                        child: new QrCamera(
                            qrCodeCallback: (code) {
                              setState(() {
                                qr = code;
                              });
                            },
                          ),
                      ),
                    )
                    : new Center(child: new Text("Camera inactive"))),
            new Text("QRCODE: $qr"),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
          child: new Text(
            "press me",
            textAlign: TextAlign.center,
          ),
          onPressed: () {
            setState(() {
              camState = !camState;
            });
          }),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  qr_mobile_vision: "^0.0.1"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:qr_mobile_vision/qr_mobile_vision.dart';
  
Version Uploaded Documentation Archive
0.0.1 Jun 5, 2018 Go to the documentation of qr_mobile_vision 0.0.1 Download qr_mobile_vision 0.0.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

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

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/qr_mobile_vision.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
native_device_orientation ^0.0.2 0.0.2
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7