fzxing 0.1.0+1 fzxing: ^0.1.0+1 copied to clipboard
A Zxing plugin to wrap zxing-android-embedded for Android and LBXScan for iOS
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fzxing/fzxing.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _barcode = 'Unknown';
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text('barcode: $_barcode\n'),
new RaisedButton(
onPressed: () {
try {
Fzxing
.scan(
isBeep: true,
isContinuous: false,
continuousInterval: 2000)
.then((barcodeResult) {
print("new bar code :" + barcodeResult.toString());
setState(() {
_barcode = barcodeResult.join(',');
});
});
} on PlatformException {
_barcode = 'Failed to get barcode.';
}
},
child: Text('scan'),
)
],
),
),
),
);
}
}