ソースを参照

update README.md

flutter-beta
TheJuliuscanute 7年前
コミット
93adab4def
8個のファイルの変更180行の追加20行の削除
  1. +1
    -1
      .packages
  2. バイナリ
      .resources/android_back_camera_flash.gif
  3. バイナリ
      .resources/android_front_camera_scan.gif
  4. バイナリ
      .resources/ios_back_camera_flash.gif
  5. バイナリ
      .resources/ios_front_camera_scan.gif
  6. バイナリ
      .resources/sample_qr_code.png
  7. +117
    -7
      README.md
  8. +62
    -12
      example/lib/main.dart

+ 1
- 1
.packages ファイルの表示

@@ -1,4 +1,4 @@
# Generated by pub on 2019-06-18 09:09:30.310062.
# Generated by pub on 2019-06-18 10:12:43.975273.
collection:file:///Users/juliuscanute/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/ collection:file:///Users/juliuscanute/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
flutter:file:///Users/juliuscanute/Library/CrossPlatform/flutter/packages/flutter/lib/ flutter:file:///Users/juliuscanute/Library/CrossPlatform/flutter/packages/flutter/lib/
meta:file:///Users/juliuscanute/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/ meta:file:///Users/juliuscanute/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/


バイナリ
.resources/android_back_camera_flash.gif ファイルの表示

変更前 変更後
幅: 320  |  高さ: 646  |  サイズ: 12 MiB

バイナリ
.resources/android_front_camera_scan.gif ファイルの表示

変更前 変更後
幅: 320  |  高さ: 646  |  サイズ: 4.7 MiB

バイナリ
.resources/ios_back_camera_flash.gif ファイルの表示

変更前 変更後
幅: 320  |  高さ: 566  |  サイズ: 6.6 MiB

バイナリ
.resources/ios_front_camera_scan.gif ファイルの表示

変更前 変更後
幅: 320  |  高さ: 535  |  サイズ: 6.9 MiB

バイナリ
.resources/sample_qr_code.png ファイルの表示

変更前 変更後
幅: 300  |  高さ: 300  |  サイズ: 2.7 KiB

+ 117
- 7
README.md ファイルの表示

@@ -1,11 +1,121 @@
# qr_code_scanner
This package wires the PlatformView corresponding to iOS and Android inside flutter.
# QR Code Scanner


# Credits
* Android: https://github.com/zxing/zxing
* iOS: https://github.com/mikebuss/MTBBarcodeScanner
* Special Thanks To: LeonDevLifeLog for his contributions towards improving this package.
A QR code scanner that works on both iOS and Android by natively embedding the platform view within Flutter. The integration with Flutter is seamless, much better than jumping into a native Activity or a ViewController to perform the scan.


## Screenshots
<table>
<tr>
<th colspan="2">
Android
</th>
</tr>

<tr>
<td>
<p align="center">
<figure>
<img src="/.resources/android_back_camera_flash.gif" width="30%" height="30%">
<figcaption>Back Camera Scan & Flash Test</figcaption>
</figure>
</p>
</td>
<td>
<p align="center">
<figure>
<img src="/.resources/android_front_camera_scan.gif" width="30%" height="30%">
<figcaption>Front Camera Scan</figcaption>
</figure>
</p>
</td>
</tr>

<tr>
<th colspan="2">
iOS
</th>
</tr>

<tr>
<td>
<p align="center">
<figure>
<img src="/.resources/ios_back_camera_flash.gif" width="30%" height="30%">
<figcaption>Back Camera Scan & Flash Test</figcaption>
</figure>
</p>
</td>
<td>
<p align="center">
<figure>
<img src="/.resources/ios_front_camera_scan.gif" width="30%" height="30%">
<figcaption>Front Camera Scan</figcaption>
</figure>
</p>
</td>
</tr>

</table>

## Get Scanned QR Code

When a QR code is recognized, the text identified will be set in 'qrText'.

```dart
class _QRViewExampleState extends State<QRViewExample> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = "";
QRViewController controller;

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
],
),
);
}

void _onQRViewCreated(QRViewController controller) {
final channel = controller.channel;
controller.init(qrKey);
this.controller = controller;
channel.setMethodCallHandler((MethodCall call) async {
switch (call.method) {
case "onRecognizeQR":
dynamic arguments = call.arguments;
setState(() {
qrText = arguments.toString();
});
}
});
}
}
```
## Flip Camera (Back/Front)
The default camera is the back camera.
```dart
controller.flipCamera();
```

## Flash (Off/On)
By default, flash is OFF.
```dart
controller.flipFlash();
```


# TODO'S: # TODO'S:
* iOS Native embedding is written to match what is supported in the framework as of the date of publication of this package. It needs to be improved as the framework support improves. * iOS Native embedding is written to match what is supported in the framework as of the date of publication of this package. It needs to be improved as the framework support improves.
* Finally, I welcome PR's to make it better :), thanks
* In future, options will be provided for default states.
* Finally, I welcome PR's to make it better :), thanks

# Credits
* Android: https://github.com/zxing/zxing
* iOS: https://github.com/mikebuss/MTBBarcodeScanner
* Special Thanks To: LeonDevLifeLog for his contributions towards improving this package.

+ 62
- 12
example/lib/main.dart ファイルの表示

@@ -4,6 +4,11 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';


void main() => runApp(MaterialApp(home: QRViewExample())); void main() => runApp(MaterialApp(home: QRViewExample()));


const flash_on = "FLASH ON";
const flash_off = "FLASH OFF";
const front_camera = "FRONT CAMERA";
const back_camera = "BACK CAMERA";

class QRViewExample extends StatefulWidget { class QRViewExample extends StatefulWidget {
const QRViewExample({ const QRViewExample({
Key key, Key key,
@@ -16,7 +21,10 @@ class QRViewExample extends StatefulWidget {
class _QRViewExampleState extends State<QRViewExample> { class _QRViewExampleState extends State<QRViewExample> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = ""; var qrText = "";
var flashState = flash_on;
var cameraState = front_camera;
QRViewController controller; QRViewController controller;

@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -30,19 +38,53 @@ class _QRViewExampleState extends State<QRViewExample> {
flex: 4, flex: 4,
), ),
Expanded( Expanded(
child: Column(children:
<Widget>[
child: Column(
children: <Widget>[
Text("This is the result of scan: $qrText"), Text("This is the result of scan: $qrText"),
RaisedButton(
onPressed: (){
if(controller != null){
controller.flipFlash();
}
},
child: Text(
'Flip',
style: TextStyle(fontSize: 20)
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(8.0),
child: RaisedButton(
onPressed: () {
if (controller != null) {
controller.flipFlash();
if (_isFlashOn(flashState))
setState(() {
flashState = flash_off;
});
else
setState(() {
flashState = flash_on;
});
}
},
child: Text(flashState, style: TextStyle(fontSize: 20)),
),
),
Container(
margin: EdgeInsets.all(8.0),
child: RaisedButton(
onPressed: () {
if (controller != null) {
controller.flipCamera();
if (_isBackCamera(cameraState))
setState(() {
cameraState = front_camera;
});
else
setState(() {
cameraState = back_camera;
});
}
},
child:
Text(cameraState, style: TextStyle(fontSize: 20)),
),
)
],
) )
], ],
), ),
@@ -53,6 +95,14 @@ class _QRViewExampleState extends State<QRViewExample> {
); );
} }


_isFlashOn(String current) {
return flash_on == current;
}

_isBackCamera(String current) {
return back_camera == current;
}

void _onQRViewCreated(QRViewController controller) { void _onQRViewCreated(QRViewController controller) {
final channel = controller.channel; final channel = controller.channel;
controller.init(qrKey); controller.init(qrKey);


読み込み中…
キャンセル
保存