flutter_mobile_vision 0.0.2

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

flutter_mobile_vision #

Codacy Badge

Flutter implementation for Google Mobile Vision.

Based on Google Mobile Vision.

Android Samples -=- iOS Samples

Liked? ⭐ Star the repo to support the project!

Features #

  • [ ] Android

    • [ ] Barcode Scan
      • [x] Simple scan.
      • [x] Toggle torch.
      • [x] Toggle auto focus.
      • [x] Specify types of barcodes that will be read.
      • [x] Tap to capture.
      • [x] Select barcode type to be scanned.
      • [x] Scan multiple barcodes.
      • [X] Barcode coordinates.
    • [ ] Recognize Text
      • [ ] Future Tasks
    • [ ] Detect Faces
      • [ ] Future Tasks
  • [ ] iOS

    • [ ] Barcode Scan
      • [ ] Future Tasks
    • [ ] Recognize Text
      • [ ] Future Tasks
    • [ ] Detect Faces
      • [ ] Future Tasks

Screenshots #

<img src="docs/flutter_01.png" height="300em"/> <img src="docs/flutter_02.png" height="300em"/> <img src="docs/flutter_03.png" height="300em"/> <img src="docs/flutter_04.png" height="300em"/>

Usage #

Example

To use this plugin :

  dependencies:
    flutter:
      sdk: flutter
    flutter_mobile_vision:
  • read a barcode:
//...
String displayValue = 'Unknown';
String rawValue = 'Unknown';
String format = 'Unknown';
String valueFormat = 'Unknown';

try {
  Barcode barcode = await FlutterMobileVision.scan();
  displayValue = barcode.displayValue;
  rawValue = barcode.rawValue;
  format = '${barcode.getFormatString()} (${barcode.format})';
  valueFormat =
      '${barcode.getValueFormatString()} (${barcode.valueFormat})';
} on Exception {
  displayValue = 'Failed to get barcode.';
}
//...

Android #

For Android, you must do the following before you can use the plugin:

  • Add the camera permission to your AndroidManifest.xml

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.CAMERA" />

  • Add the Barcode activity to your AndroidManifest.xml

    <activity android:name="io.github.edufolly.fluttermobilevision.BarcodeCaptureActivity" />

iOS #

If you can help, the community thanks. Your fork is needed. 😉

[0.0.2] - 2018-04-23

  • Multiple Scans.
  • And a lot of new features.

[0.0.1] - 2018-04-22

  • Basic test functions.
  • Only Scan Barcodes.
  • Only Android support.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';

void main() => runApp(new MyApp());

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

class _MyAppState extends State<MyApp> {
  int _onlyFormat = Barcode.ALL_FORMATS;
  bool _autoFocus = true;
  bool _torch = false;
  bool _multiple = false;
  bool _waitTap = false;

  List<Barcode> _barcodes = [];

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

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      theme: new ThemeData(
        primarySwatch: Colors.lime,
        buttonColor: Colors.lime,
      ),
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Flutter Mobile Vision'),
        ),
        body: new ListView(
          padding: const EdgeInsets.only(
            top: 12.0,
          ),
          children: _getItems(context),
        ),
      ),
    );
  }

  List<DropdownMenuItem<int>> _getFormats() {
    List<DropdownMenuItem<int>> formatItems = [];

    Barcode.mapFormat.forEach((key, value) {
      formatItems.add(new DropdownMenuItem(
        child: new Text(value),
        value: key,
      ));
    });

    return formatItems;
  }

  List<Widget> _getItems(BuildContext context) {
    List<Widget> items = [];

    items.add(new Padding(
      padding: const EdgeInsets.only(
        top: 8.0,
        left: 18.0,
        right: 18.0,
      ),
      child: new Text('Scan format only:'),
    ));

    items.add(new Padding(
      padding: const EdgeInsets.only(
        left: 18.0,
        right: 18.0,
      ),
      child: new DropdownButton(
        items: _getFormats(),
        onChanged: (value) => setState(
              () => _onlyFormat = value,
            ),
        value: _onlyFormat,
      ),
    ));

    items.add(new SwitchListTile(
      title: new Text('Auto focus:'),
      value: _autoFocus,
      onChanged: (value) => setState(() => _autoFocus = value),
    ));

    items.add(new SwitchListTile(
      title: new Text('Torch:'),
      value: _torch,
      onChanged: (value) => setState(() => _torch = value),
    ));

    items.add(new SwitchListTile(
      title: new Text('Multiple Scan:'),
      value: _multiple,
      onChanged: (value) => setState(() {
            _multiple = value;
            if (value) _waitTap = true;
          }),
    ));

    items.add(new SwitchListTile(
      title: new Text('Wait a tap to capture:'),
      value: _waitTap,
      onChanged: (value) => setState(() {
            _waitTap = value;
            if (!value) _multiple = false;
          }),
    ));

    items.add(
      new Padding(
        padding: const EdgeInsets.only(
          left: 18.0,
          right: 18.0,
          bottom: 12.0,
        ),
        child: new RaisedButton(
          onPressed: _scan,
          child: new Text('SCAN!'),
        ),
      ),
    );

    items.addAll(
      ListTile.divideTiles(
        context: context,
        tiles: _barcodes
            .map(
              (barcode) => new BarcodeWidget(barcode),
            )
            .toList(),
      ),
    );

    return items;
  }

  Future<Null> _scan() async {
    List<Barcode> barcodes = [];
    try {
      barcodes = await FlutterMobileVision.scan(
        flash: _torch,
        autoFocus: _autoFocus,
        formats: _onlyFormat,
        multiple: _multiple,
        waitTap: _waitTap,
      );
    } on Exception {
      barcodes.add(new Barcode('Failed to get barcode.'));
    }

    if (!mounted) return;

    setState(() => _barcodes = barcodes);
  }
}

class BarcodeWidget extends StatelessWidget {
  final Barcode barcode;

  BarcodeWidget(this.barcode);

  @override
  Widget build(BuildContext context) {
    return new ListTile(
      leading: const Icon(Icons.star),
      title: new Text(barcode.displayValue),
      subtitle: new Text(
        '${barcode.getFormatString()} (${barcode.format}) - '
            '${barcode.getValueFormatString()} (${barcode.valueFormat})',
      ),
      trailing: const Icon(Icons.arrow_forward),
      onTap: () => Navigator.of(context).push(
            new MaterialPageRoute(
              builder: (context) => new BarcodeDetails(barcode),
            ),
          ),
    );
  }
}

class BarcodeDetails extends StatefulWidget {
  final Barcode barcode;

  BarcodeDetails(this.barcode);

  @override
  _BarcodeDetailsState createState() => new _BarcodeDetailsState();
}

class _BarcodeDetailsState extends State<BarcodeDetails> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Barcode Details'),
      ),
      body: new ListView(
        children: <Widget>[
          new ListTile(
            title: new Text(widget.barcode.displayValue),
            subtitle: const Text('Display Value'),
          ),
          new ListTile(
            title: new Text(widget.barcode.rawValue),
            subtitle: const Text('Raw Value'),
          ),
          new ListTile(
            title: new Text('${widget.barcode.getFormatString()} '
                '(${widget.barcode.format})'),
            subtitle: const Text('Format'),
          ),
          new ListTile(
            title: new Text('${widget.barcode.getValueFormatString()} '
                '(${widget.barcode.valueFormat})'),
            subtitle: const Text('Value Format'),
          ),
          new ListTile(
            title: new Text(widget.barcode.top.toString()),
            subtitle: const Text('Top'),
          ),
          new ListTile(
            title: new Text(widget.barcode.bottom.toString()),
            subtitle: const Text('Bottom'),
          ),
          new ListTile(
            title: new Text(widget.barcode.left.toString()),
            subtitle: const Text('Left'),
          ),
          new ListTile(
            title: new Text(widget.barcode.right.toString()),
            subtitle: const Text('Right'),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_mobile_vision: ^0.0.2

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:flutter_mobile_vision/flutter_mobile_vision.dart';
  
Version Uploaded Documentation Archive
0.1.3 Dec 23, 2018 Go to the documentation of flutter_mobile_vision 0.1.3 Download flutter_mobile_vision 0.1.3 archive
0.1.2 Dec 16, 2018 Go to the documentation of flutter_mobile_vision 0.1.2 Download flutter_mobile_vision 0.1.2 archive
0.1.1 Jul 8, 2018 Go to the documentation of flutter_mobile_vision 0.1.1 Download flutter_mobile_vision 0.1.1 archive
0.1.0 May 7, 2018 Go to the documentation of flutter_mobile_vision 0.1.0 Download flutter_mobile_vision 0.1.0 archive
0.0.4 May 4, 2018 Go to the documentation of flutter_mobile_vision 0.0.4 Download flutter_mobile_vision 0.0.4 archive
0.0.3 May 2, 2018 Go to the documentation of flutter_mobile_vision 0.0.3 Download flutter_mobile_vision 0.0.3 archive
0.0.2 Apr 23, 2018 Go to the documentation of flutter_mobile_vision 0.0.2 Download flutter_mobile_vision 0.0.2 archive
0.0.1 Apr 23, 2018 Go to the documentation of flutter_mobile_vision 0.0.1 Download flutter_mobile_vision 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
86
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
77
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.13
  • Flutter: 1.2.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

46 out of 46 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

The package description is too short. (-13 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-a <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8