Преглед на файлове

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/
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/


Двоични данни
.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:
* 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()));

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

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

@override
Widget build(BuildContext context) {
return Scaffold(
@@ -30,19 +38,53 @@ class _QRViewExampleState extends State<QRViewExample> {
flex: 4,
),
Expanded(
child: Column(children:
<Widget>[
child: Column(
children: <Widget>[
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) {
final channel = controller.channel;
controller.init(qrKey);


Зареждане…
Отказ
Запис