flutter_qr_scan 1.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • new58

flutter_qr_scan #

QR code (scan code / picture) recognition, forked from hetian9288/flutter_qr_reader.

We added Bytes/RawData reading from QR code, so onScan() callback function have 2 params now:

Future onScan(String data, String rawData) async {
 print(data);
 print(rawData);
}

Docs can be found in hetian9288/flutter_qr_reader.

0.0.1 #

0.0.2 #

增加内置UI

0.0.3 #

0.0.4 #

0.0.5 #

1.0.0 #

1.0.0+1 #

1.0.1 #

修改扫码后的操作

1.0.2 #

降低zxing版本至3.3.3

1.0.3 #

解决scanBoxRatio无效问题

1.0.4 #

Add Bytes/RawData reading

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_qr_scan/flutter_qr_scan.dart';
import 'package:flutter_qr_scan_example/scanViewDemo.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: HomePage());
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

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

class _HomePageState extends State<HomePage> {
  QrReaderViewController _controller;
  bool isOk = false;
  String data;
  String rawData;
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            FlatButton(
              onPressed: () async {
                Map<PermissionGroup, PermissionStatus> permissions =
                    await PermissionHandler()
                        .requestPermissions([PermissionGroup.camera]);
                print(permissions);
                if (permissions[PermissionGroup.camera] ==
                    PermissionStatus.granted) {
                  showDialog(
                    context: context,
                    builder: (context) {
                      return Dialog(
                        child: Text("ok"),
                      );
                    },
                  );
                  setState(() {
                    isOk = true;
                  });
                }
              },
              child: Text("请求权限"),
              color: Colors.blue,
            ),
            FlatButton(
              onPressed: () async {
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => ScanViewDemo()));
              },
              child: Text("独立UI"),
            ),
            FlatButton(
                onPressed: () async {
                  var image =
                      await ImagePicker.pickImage(source: ImageSource.gallery);
                  if (image == null) return;
                  final rest = await FlutterQrReader.imgScan(image);
                  setState(() {
                    data = rest;
                  });
                },
                child: Text("识别图片")),
            FlatButton(
                onPressed: () {
                  assert(_controller != null);
                  _controller.setFlashlight();
                },
                child: Text("切换闪光灯")),
            FlatButton(
                onPressed: () {
                  assert(_controller != null);
                  _controller.startCamera(onScan);
                },
                child: Text("开始扫码(暂停后)")),
            if (data != null) Text(data),
            if (isOk)
              Container(
                width: 320,
                height: 350,
                child: QrReaderView(
                  width: 320,
                  height: 350,
                  callback: (container) {
                    this._controller = container;
                    _controller.startCamera(onScan);
                  },
                ),
              )
          ],
        ),
      ),
    );
  }

  void onScan(String v, List<Offset> offsets, String rawData) {
    print([v, offsets, rawData]);
    setState(() {
      data = v;
      rawData = rawData;
    });
    _controller.stopCamera();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_qr_scan: ^1.0.4

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_scan/flutter_qr_scan.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
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]
58
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package does not support Flutter platform ios

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package does not support Flutter platform linux

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package does not support Flutter platform macos

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package does not support Flutter platform web

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package does not support Flutter platform windows

Because of import path [package:flutter_qr_scan/flutter_qr_scan.dart] that declares support for platforms:

Package not compatible with SDK dart

because of import path [flutter_qr_scan] that is in a package requiring null.

Health suggestions

Fix lib/qrcode_reader_view.dart. (-0.50 points)

Analysis of lib/qrcode_reader_view.dart reported 1 hint:

line 111 col 35: 'pickImage' is deprecated and shouldn't be used. Use imagePicker.getImage() method instead..

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
image_picker ^0.6.0+9 0.6.7+3
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
flutter_plugin_android_lifecycle 1.0.8
http 0.12.1
http_parser 3.1.4
image_picker_platform_interface 1.1.0
meta 1.1.8
path 1.7.0
pedantic 1.9.0 1.9.1
plugin_platform_interface 1.0.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test