From 1afdeab3b1015689b0f9331c5078cc9191b0ed92 Mon Sep 17 00:00:00 2001 From: TheJuliuscanute Date: Mon, 24 Dec 2018 08:33:12 +1100 Subject: [PATCH] QR Code scanner README Updates. --- CHANGELOG.md | 4 + README.md | 19 ++--- example/README.md | 82 ++++++++++++++++--- example/lib/main.dart | 14 ++-- ios/Classes/FlutterQrPlugin.m | 2 +- ...ter_qr.podspec => qr_code_scanner.podspec} | 11 +-- pubspec.yaml | 6 +- 7 files changed, 99 insertions(+), 39 deletions(-) rename ios/{flutter_qr.podspec => qr_code_scanner.podspec} (62%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f789da..0ed9180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.2 + +* Added documentation to cover how to use the plugin. + ## 0.0.1 * QR Code scanner embedded inside flutter. diff --git a/README.md b/README.md index 086ca99..d9f9af3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,11 @@ -# flutter_qr +# qr_code_scanner This package wires the PlatformView corresponding to iOS and Android inside flutter. +#Credits +* Android: https://github.com/zxing/zxing +* iOS: https://github.com/mikebuss/MTBBarcodeScanner -## Getting Started - -This project is a starting point for a Flutter -[plug-in package](https://flutter.io/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. - -For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +#TODO'S: +* Add support to flip camera view. +* 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 diff --git a/example/README.md b/example/README.md index 7a2b3ca..e7f3350 100644 --- a/example/README.md +++ b/example/README.md @@ -1,22 +1,80 @@ # qr_code_scanner Demonstrates how to use the qr_code_scanner plugin. +##iOS Support: +###info.plist +```xml + + io.flutter.embedded_views_preview + + UIBackgroundModes + + fetch + remote-notification + + NSCameraUsageDescription + Can we access your camera in order to scan barcodes? + -TODO'S: -1) Add support to flip camera view. -2) iOS Native embedding is written to match what is supported in framework as of the date of publication of this package. It needs to be improved as the framework support improves. -3) Finally, I welcome PR's to make it better :), thanks! +``` -## Getting Started +##Example: +```dart +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qr_code_scanner/qr_code_scanner.dart'; -This project is a starting point for a Flutter application. +void main() => runApp(MaterialApp(home: QRViewExample())); + +class QRViewExample extends StatefulWidget { + const QRViewExample({ + Key key, + }) : super(key: key); + + @override + State createState() => _QRViewExampleState(); +} + +class _QRViewExampleState extends State { + final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); + var qrText = ""; + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Expanded( + child: QRView( + key: qrKey, + onQRViewCreated: _onQRViewCreated, + ), + flex: 4, + ), + Expanded( + child: Text("This is the result of scan: $qrText"), + flex: 1, + ) + ], + ), + ); + } + + void _onQRViewCreated(QRViewController controller) { + final channel = controller.channel; + controller.init(qrKey); + channel.setMethodCallHandler((MethodCall call) async { + switch (call.method) { + case "onRecognizeQR": + dynamic arguments = call.arguments; + setState(() { + qrText = arguments.toString(); + }); + } + }); + } +} +``` -A few resources to get you started if this is your first Flutter project: -- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) -For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/example/lib/main.dart b/example/lib/main.dart index fcc577f..89d3154 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,18 +2,18 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart'; -void main() => runApp(MaterialApp(home: TextViewExample())); +void main() => runApp(MaterialApp(home: QRViewExample())); -class TextViewExample extends StatefulWidget { - const TextViewExample({ +class QRViewExample extends StatefulWidget { + const QRViewExample({ Key key, }) : super(key: key); @override - State createState() => _TextViewExampleState(); + State createState() => _QRViewExampleState(); } -class _TextViewExampleState extends State { +class _QRViewExampleState extends State { final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); var qrText = ""; @override @@ -26,11 +26,11 @@ class _TextViewExampleState extends State { key: qrKey, onQRViewCreated: _onQRViewCreated, ), - flex: 1, + flex: 4, ), Expanded( child: Text("This is the result of scan: $qrText"), - flex: 4, + flex: 1, ) ], ), diff --git a/ios/Classes/FlutterQrPlugin.m b/ios/Classes/FlutterQrPlugin.m index 5e8467f..650f8dd 100644 --- a/ios/Classes/FlutterQrPlugin.m +++ b/ios/Classes/FlutterQrPlugin.m @@ -1,5 +1,5 @@ #import "FlutterQrPlugin.h" -#import +#import "qr_code_scanner-Swift.h" @implementation FlutterQrPlugin + (void)registerWithRegistrar:(NSObject*)registrar { [SwiftFlutterQrPlugin registerWithRegistrar:registrar]; diff --git a/ios/flutter_qr.podspec b/ios/qr_code_scanner.podspec similarity index 62% rename from ios/flutter_qr.podspec rename to ios/qr_code_scanner.podspec index a950cec..b71df1b 100644 --- a/ios/flutter_qr.podspec +++ b/ios/qr_code_scanner.podspec @@ -1,16 +1,17 @@ # # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # + Pod::Spec.new do |s| - s.name = 'flutter_qr' - s.version = '0.0.1' - s.summary = 'A new Flutter project.' + s.name = 'qr_code_scanner' + s.version = '0.0.2' + s.summary = 'QR Code Scanner for flutter.' s.description = <<-DESC A new Flutter project. DESC - s.homepage = 'http://example.com' + s.homepage = 'https://github.com/juliuscanute/qr_code_scanner' s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } + s.author = { 'Your Company' => 'juliuscanute[*]touchcapture.net' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' diff --git a/pubspec.yaml b/pubspec.yaml index b017ef3..c3ae931 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: qr_code_scanner -description: QR code scanner natively embedded inside flutter. -version: 0.0.1 +description: QR code scanner that can be embedded inside flutter. It uses zxing in Android and MTBBarcode scanner in iOS. +version: 0.0.2 author: Julius Canute -homepage: https://medium.com/@juliuscanute +homepage: https://github.com/juliuscanute/qr_code_scanner environment: sdk: ">=2.0.0-dev.68.0 <3.0.0"