我不确定如何将其纳入现有的颤振项目中,我无法在线找到任何有用的指南或提示 . 我正在寻求实现仅2D条形码扫描仪,并且现有的颤动条形码扫描仪都没有这个选项 .
我知道ZXing还有2d功能,所以如果有人能指出我如何在颤动中实现它们,我可以动摇使用它
请检查此网址
https://pub.dartlang.org/packages/qrcode_reader这是实现代码
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:qrcode_reader/QRCodeReader.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'QRCode Reader Demo', home: new MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; final Map<String, dynamic> pluginParameters = { }; @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { Future<String> _barcodeString; @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: const Text('QRCode Reader Example'), ), body: new Center( child: new FutureBuilder<String>( future: _barcodeString, builder: (BuildContext context, AsyncSnapshot<String> snapshot) { return new Text(snapshot.data != null ? snapshot.data : ''); })), floatingActionButton: new FloatingActionButton( onPressed: () { setState(() { _barcodeString = new QRCodeReader() .setAutoFocusIntervalInMs(200) .setForceAutoFocus(true) .setTorchEnabled(true) .setHandlePermissions(true) .setExecuteAfterPermissionGranted(true) .scan(); }); }, tooltip: 'Reader the QRCode', child: new Icon(Icons.add_a_photo), ), ); } }
这可以通过使用flutter barcode_scan dependency来完成 .
Future _openQRScanner() async { try { // Below code will open camera preview and return result after qr scan String _content = await BarcodeScanner.scan(); setState(() => this._content = _content); } on PlatformException catch (e) { if (e.code == BarcodeScanner.CameraAccessDenied) { showSnackBar('Please grant camera permission!'); setState(() { this._content = null; }); } else { showSnackBar('Error: $e'); setState(() { this._content = null; }); } } on FormatException { showSnackBar('User pressed "back" button before scanning'); setState(() { this._content = null; }); } catch (e) { showSnackBar('Error: $e'); setState(() { this._content = null; }); } }
请找到repo .
如果你想看看Flutter,你可以在我们的companie’s Github页面找到一些很好的例子 . 另外,您可以查看我们公司的页面FlutterDevs .
2 回答
请检查此网址
https://pub.dartlang.org/packages/qrcode_reader这是实现代码
这可以通过使用flutter barcode_scan dependency来完成 .
请找到repo .
如果你想看看Flutter,你可以在我们的companie’s Github页面找到一些很好的例子 . 另外,您可以查看我们公司的页面FlutterDevs .