diff --git a/.packages b/.packages
index c9e0bc2..a079126 100644
--- a/.packages
+++ b/.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/
diff --git a/.resources/android_back_camera_flash.gif b/.resources/android_back_camera_flash.gif
new file mode 100644
index 0000000..d20a3b9
Binary files /dev/null and b/.resources/android_back_camera_flash.gif differ
diff --git a/.resources/android_front_camera_scan.gif b/.resources/android_front_camera_scan.gif
new file mode 100644
index 0000000..f6d150a
Binary files /dev/null and b/.resources/android_front_camera_scan.gif differ
diff --git a/.resources/ios_back_camera_flash.gif b/.resources/ios_back_camera_flash.gif
new file mode 100644
index 0000000..d6c9ec1
Binary files /dev/null and b/.resources/ios_back_camera_flash.gif differ
diff --git a/.resources/ios_front_camera_scan.gif b/.resources/ios_front_camera_scan.gif
new file mode 100644
index 0000000..721842a
Binary files /dev/null and b/.resources/ios_front_camera_scan.gif differ
diff --git a/.resources/sample_qr_code.png b/.resources/sample_qr_code.png
new file mode 100644
index 0000000..45892b8
Binary files /dev/null and b/.resources/sample_qr_code.png differ
diff --git a/README.md b/README.md
index 3b4c8ac..81a2f89 100644
--- a/README.md
+++ b/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
+
+
+
+Android
+
+
+
+
+
+
+
+
+Back Camera Scan & Flash Test
+
+
+
+
+
+
+
+Front Camera Scan
+
+
+
+
+
+
+
+iOS
+
+
+
+
+
+
+
+
+Back Camera Scan & Flash Test
+
+
+
+
+
+
+
+Front Camera Scan
+
+
+
+
+
+
+
+## Get Scanned QR Code
+
+When a QR code is recognized, the text identified will be set in 'qrText'.
+
+```dart
+class _QRViewExampleState extends State {
+ final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
+ var qrText = "";
+ QRViewController controller;
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ body: Column(
+ children: [
+ 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
\ No newline at end of file
+* 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.
\ No newline at end of file
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 1b39039..00db09e 100644
--- a/example/lib/main.dart
+++ b/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 {
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 {
flex: 4,
),
Expanded(
- child: Column(children:
- [
+ child: Column(
+ children: [
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: [
+ 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 {
);
}
+ _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);