Coder Social home page Coder Social logo

qr_code_scanner's Introduction

Project in Maintenance Mode Only

Since the underlying frameworks of this package, zxing for android and MTBBarcodescanner for iOS are both not longer maintaned, this plugin is no longer up to date and in maintenance mode only. Only bug fixes and minor enhancements will be considered.

I am developing a new plugin mobile_scanner that uses the latest version of MLKit for detecting barcodes and QR codes. On Android it also uses the latest version of CameraX, and on iOS the native AVFoundation for best camera performance.

QR Code Scanner

pub package Join the chat GH Actions

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

iOS

Get Scanned QR Code

When a QR code is recognized, the text identified will be set in 'result' of type Barcode, which contains the output text as property 'code' of type String and scanned code type as property 'format' which is an enum BarcodeFormat, defined in the library.

class _QRViewExampleState extends State<QRViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  Barcode? result;
  QRViewController? controller;

  // In order to get hot reload to work we need to pause the camera if the platform
  // is android, or resume the camera if the platform is iOS.
  @override
  void reassemble() {
    super.reassemble();
    if (Platform.isAndroid) {
      controller!.pauseCamera();
    } else if (Platform.isIOS) {
      controller!.resumeCamera();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            flex: 5,
            child: QRView(
              key: qrKey,
              onQRViewCreated: _onQRViewCreated,
            ),
          ),
          Expanded(
            flex: 1,
            child: Center(
              child: (result != null)
                  ? Text(
                      'Barcode Type: ${describeEnum(result!.format)}   Data: ${result!.code}')
                  : Text('Scan a code'),
            ),
          )
        ],
      ),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    this.controller = controller;
    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }
}

Android Integration

In order to use this plugin, please update the Gradle, Kotlin and Kotlin Gradle Plugin:

In android/build.gradle change ext.kotlin_version = '1.3.50' to ext.kotlin_version = '1.5.10'

In android/build.gradle change classpath 'com.android.tools.build:gradle:3.5.0' to classpath 'com.android.tools.build:gradle:4.2.0'

In android/gradle/wrapper/gradle-wrapper.properties change distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip to distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip

In android/app/build.gradle change defaultConfig{ ... minSdkVersion 16 } to defaultConfig{ ... minSdkVersion 20 }

Warning

If you are using Flutter Beta or Dev channel (1.25 or 1.26) you can get the following error:

java.lang.AbstractMethodError: abstract method "void io.flutter.plugin.platform.PlatformView.onFlutterViewAttached(android.view.View)"

This is a bug in Flutter which is being tracked here: flutter/flutter#72185

There is a workaround by adding android.enableDexingArtifactTransform=false to your gradle.properties file.

iOS Integration

In order to use this plugin, add the following to your Info.plist file:

<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>

Web Integration

Add this to web/index.html:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jsQR.min.js"></script>

Please note: on web, only QR codes are supported. Other barcodes and 2D codes cannot be scanned.

Web support is in very early stage. Features such as flash, pause or resume are not implemented. Moreover, the camera preview does not respect the surrounding constraints. This is not at last due to Flutter's early state of platform views on web.

Flip Camera (Back/Front)

The default camera is the back camera.

await controller.flipCamera();

Flash (Off/On)

By default, flash is OFF.

await controller.toggleFlash();

Resume/Pause

Pause camera stream and scanner.

await controller.pauseCamera();

Resume camera stream and scanner.

await controller.resumeCamera();

SDK

Requires at least SDK 20. Requires at least iOS 8.

TODOs

  • 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.
  • In future, options will be provided for default states.
  • Finally, I welcome PR's to make it better :), thanks

Credits

qr_code_scanner's People

Contributors

akkalbhor avatar belfdev avatar dependabot[bot] avatar dhi13man avatar dspicher avatar enricobenedos avatar felpsio avatar ingenieria-indimin avatar jawa0919 avatar juliansteenbakker avatar juliuscanute avatar leondevlifelog avatar luisthein avatar mikeesouth avatar monsieurtanuki avatar ootpappsdotcom avatar operator-name avatar orangesofter avatar rag3h avatar reidlai avatar stepan-bezhuk-axon avatar szotp avatar theonewiththebraid avatar tvh avatar vanlooverenkoen avatar via-guy avatar viniciussossela avatar xebastian avatar xeinebiu avatar ziyadf296 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qr_code_scanner's Issues

IOS Error running pod install

I am getting this issue when trying to run on ios simulator

Comparing resolved specification to the sandbox manifest
A Flutter
A MTBBarcodeScanner
A qr_code_scanner

Downloading dependencies

-> Installing Flutter (1.0.0)

-> Installing MTBBarcodeScanner (5.0.11)
  > Copying MTBBarcodeScanner from `/Users/amitabhsarkar/Library/Caches/CocoaPods/Pods/Release/MTBBarcodeScanner/5.0.11-f453b` to `Pods/MTBBarcodeScanner`

-> Installing qr_code_scanner (0.0.2)
  - Running pre install hooks
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `qr_code_scanner` depends upon `MTBBarcodeScanner`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/target_validator.rb:151:in `verify_swift_pods_have_module_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/target_validator.rb:40:in `validate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:590:in `validate_targets'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:158:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:

�[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8
    �[0m

Error running pod install
Error launching application on iPhone 11 Pro Max.

Other Barcode Formats

I really like your scanner and the fact that I can customize the widget that it displays in. Nice work.

I am hoping that there is a way to use it also scan other types of 2D and even 1D barcodes as well? In particular, I need to scan PDF417 and Aztec barcodes, as well as 3 of 9 (code 39).

I was really hoping that being based on the ZXing libraries, this would be possible.

Please tell me I just need to change the value of the qrKey or something equally simple. ;)

Thank you.

[ASK] Why use minSdkVersion 21?

Your plugin is very helpful, we can use it with custom view. But, why you decide to use Android API 21 for minimum SDK version? Why not using API 16 as minimum SDK version since it's recommended minimum SDK version from Android Studio? Thanks

Failed to build iOS app

Launching lib/main.dart on iPhone Andrey in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: WRYNMB2729
Running pod install...
Running Xcode build...
Xcode build done. 4,7s
Failed to build iOS app
Error output from Xcode build:

2019-08-18 10:17:42.711 xcodebuild[36516:1089909] DTDeviceKit: deviceType from 1b083cf7ccc9ab170d1f15ea75cdc91d161ebc5c was NULL
2019-08-18 10:17:42.765 xcodebuild[36516:1089913] DTDeviceKit: deviceType from 1b083cf7ccc9ab170d1f15ea75cdc91d161ebc5c was NULL
** BUILD FAILED **

Xcode's output:

warning: The iOS deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.4.99. (in target 'Flutter')
/Users/andrey/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.0.12/ios/Classes/FlutterQrPlugin.m:2:9: fatal error: 'qr_code_scanner/qr_code_scanner-Swift.h' file not found
#import "qr_code_scanner/qr_code_scanner-Swift.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Runner-hkmsyoepzonlwvejomucogedgxxm
note: Using new build systemnote: Planning buildnote: Constructing build description

Could not build the precompiled application for the device.

It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
open ios/Runner.xcworkspace

Error launching application on iPhone Andrey.

Change return [ASK]

hello im having some trouble handling the data back from the QR reader

im trying to read a binary QR 2D em transform de data to a base64 string to be compared to an existing base 64;

here below is the code im using:

void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {

  var bytes = utf8.encode(scanData);
  print(base64.encode(bytes));

  setState(() {
    qrText = scanData;
  });
});

}

this is the output:
Xe+/vXENBQARAEUwQwIgXUdMOe+/vQbvv73vv73vv70LSTvvv71E77+9KE/vv73IsO+/vV/vv73vv70J77+9b++/vSTvv71P77+9Ah8eya9l77+9R++/ve+/ve+/vU3vv73vv73vv71Y77+9SGTvv71jUTnvv73vv70b77+9C1kr77+977+9KgAAAAxF77+9UEEUEGVEVlFF77+9

this is what it should be :
XaRxDQUAEQBFMEMCIF1HTDnDBpuxtwtJO/1E4ShPxMiw5l+HkgmZb7skqk+KAh8eya9lrEe3sYhNwczoWLRIZJBjUTmd3hvcC1kr+YUqAAAADEWUUEEUEGVEVlFFwA==

the conversion is wrong and i dont think its my code, but i think it is becaude the type of return of the variable, i need the raw data from de reading..

is there a way to do it on this lib ??

in native android a use the zxing lib and get it from the mMap of the data...but i dont see a way to do it here

here is the QR im trying to read.
WhatsApp Image 2019-11-05 at 15 45 19

[android]bug when unlock screen

after close page that contained a QRView,not exit app(not tap home button),lock screen directly, camera opened on the background after unlock screen.

Critical Crash in iOS

I have been using this plugin for a while now and it was fine, but recently in the latest iOS versions (13.1.3 onwards) my app closes unexpectedly while scanning... It is a crash in some native level because I have implemented Crash Reports in my app and it doesn't get noticed... the app just closes itself. It is not a constant thing I mean sometimes I can scan 100 codes but it crashes at 101, other times it crashes at 5 code scans... it is something random but always crashes for sure.
In order to discard any bug related to my app I created an example project to test specifically this plugin v0.0.12 and it crashes in the same way.

Note 0: in the _onQRViewCreated in this example I use pauseCamera() and resumeCamera() with a Future.delay() to simulate an API request delay but I also tested without this pause/resume delay and it crashes the same

Note 1: I have tested in iPhone6S with iOS 13.2, iPhone 6S Plus with iOS 13.1.3, iPhone X with iOS 13.1.3 and iPad 6th Generation with iOS 13.2

Note 2: In Android it seems to work fine the app doesn't crash.

I used the exact main.dart for the example of this plugin and just added a scansCount to know when exactly it crashes...
[Edited main with sync and async scans simulation]
main.dart.txt

Reduce stream speed?

Currently I am scanning for QR codes and whenever something is found, I open an alert to show the information of the QR code, however the scannedDataStream provides information so fast that it opens like 20 alert dialogs within a second.

How can I reduce the stream speed? (or amount of scans that are being done)

  void _onQRViewCreated(QRViewController controller) {
    this.controller = controller;
    controller.scannedDataStream.listen((scanData) {
      setState(() {
        qrText = scanData;
      });
      displayDialog(scanData);
    });
  }

Thanks in advance!

flutter build apk -> failed (resources not found android:attr/fontVariationSettings android:attr/ttcIndex) + solution

Hello
Using the standard imported package, my application works in the emulator, but I cannot package it as release.
I can use the app-debug.apk generated for the emulator on my devices, yet I cannot package properly.

This is the error, which seems to be related to AndroidX (which I don't use in my Flutter app)

...
Execution failed for task ':qr_code_scanner:verifyReleaseResources'.    
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  Output:  /home/gl/dev/projects/nautilusboarding/build/qr_code_scanner/intermediates/res/merged/release/values/values.xml:199: error: resource android:attr/fontVariationSettings not found.
  /home/gl/dev/projects/nautilusboarding/build/qr_code_scanner/intermediates/res/merged/release/values/values.xml:200: error: resource android:attr/ttcIndex not found.
  error: failed linking references.                                     
...

My solution for being able to generate the app-release.apk package, is to patch the file in:
Project -> External Libraries -> Flutter Plugins -> qr_code_scanner_0.0.5/android/gradle.properties
by removing the AndroidX references

--- gradle.properties.orig	2019-05-11 15:39:22.631938230 +0200
+++ gradle.properties	2019-05-11 15:39:25.063938165 +0200
@@ -1,3 +1 @@
 org.gradle.jvmargs=-Xmx1536M
-android.enableJetifier=true
-android.useAndroidX=true

Seems that AndroidX is not required for qr_code_scanner itself to work
Now I can properly build the release package.

Cheers
Gianluca

CRASH -> Fatal Exception: java.lang.ArithmeticException divide by zero

Getting many crashes with this error. Think it is caused by ZXing package. Check journeyapps/zxing-android-embedded#334

Error:

Fatal Exception: java.lang.ArithmeticException: divide by zero
       at com.journeyapps.barcodescanner.CameraPreview.j + 71(CameraPreview.java:71)
       at com.journeyapps.barcodescanner.CameraPreview.b + 6(CameraPreview.java:6)
       at com.journeyapps.barcodescanner.CameraPreview.access$300(CameraPreview.java)
       at com.journeyapps.barcodescanner.CameraPreview$3.handleMessage + 12(CameraPreview.java:12)
       at android.os.Handler.dispatchMessage + 102(Handler.java:102)
       at android.os.Looper.loop + 214(Looper.java:214)
       at android.app.ActivityThread.main + 7078(ActivityThread.java:7078)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 493(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main + 964(ZygoteInit.java:964)

Failed run project in iOS

Hi, this on result error from my side

The Swift pod qr_code_scanner depends upon MTBBarcodeScanner, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.
No matching processes belonging to you were found
[ +5 ms] Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
brew install cocoapods
pod setup

Encountered error while building for device.

Have any fixed issue before @juliuscanute ?

Example seems outdated

The example has public access to the channel and controller, but it appears those were removed last month:

QRViewController updated

- MethodChannel is now handled inside the controller
- Removed controller init, pass globalKey as required parameter
- Controller now returns a stream of data
- Updated README.md + example```

Is this true, can you update the example?

Crash after permission of camera

Hello I have a crash after accept permissin of the camera.

here is the repport :

D/CameraPreview( 6772): resume()
W/CameraPreview( 6772): initCamera called twice
D/SensorManager( 6772): unregisterListener ::   
D/SensorManager( 6772): registerListener :: 1, K6DS3TR Acceleration Sensor, 200000, 0,  
D/CameraPreview( 6772): pause()
D/CameraInstance( 6772): Closing camera
D/SensorManager( 6772): unregisterListener ::   
V/InputMethodManager( 6772): Not IME target window, ignoring
D/ViewRootImpl@2e52b00[MainActivity]( 6772): dispatchAttachedToWindow
V/Surface ( 6772): sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@2e52b00[MainActivity]( 6772): Relayout returned: old=[0,0][0,0] new=[0,0][696,996] result=0x7 surface={valid=true 504886788096} changed=true
D/mali_winsys( 6772): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [696x996]-format:1
D/OpenGLRenderer( 6772): eglCreateWindowSurface = 0x75b8428a50
D/ViewRootImpl@2e52b00[MainActivity]( 6772): MSG_RESIZED_REPORT: frame=Rect(0, 0 - 696, 996) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ViewRootImpl@32cd41e[MainActivity]( 6772): MSG_WINDOW_FOCUS_CHANGED 0
V/Surface ( 6772): sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@32cd41e[MainActivity]( 6772): MSG_WINDOW_FOCUS_CHANGED 1
V/InputMethodManager( 6772): Starting input: tba=android.view.inputmethod.EditorInfo@d9f8edf nm : fr.test.testmaj ic=null
I/InputMethodManager( 6772): startInputInner - mService.startInputOrWindowGainedFocus
D/AndroidRuntime( 6772): Shutting down VM
E/AndroidRuntime( 6772): FATAL EXCEPTION: main
E/AndroidRuntime( 6772): Process: fr.test.testmaj, PID: 6772
E/AndroidRuntime( 6772): java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=513469796, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {fr.test.testmaj/fr.test.testmaj.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void java.lang.Runnable.run()' on a null object reference
E/AndroidRuntime( 6772): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4491)
E/AndroidRuntime( 6772): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4534)
E/AndroidRuntime( 6772): 	at android.app.ActivityThread.-wrap20(Unknown Source:0)
E/AndroidRuntime( 6772): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
E/AndroidRuntime( 6772): 	at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime( 6772): 	at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime( 6772): 	at android.app.ActivityThread.main(ActivityThread.java:6944)
E/AndroidRuntime( 6772): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6772): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
E/AndroidRuntime( 6772): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
E/AndroidRuntime( 6772): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void java.lang.Runnable.run()' on a null object reference
E/AndroidRuntime( 6772): 	at io.flutter.plugins.camera.CameraPlugin$CameraRequestPermissionsListener.onRequestPermissionsResult(CameraPlugin.java:230)
E/AndroidRuntime( 6772): 	at io.flutter.app.FlutterPluginRegistry.onRequestPermissionsResult(FlutterPluginRegistry.java:194)
E/AndroidRuntime( 6772): 	at io.flutter.app.FlutterActivityDelegate.onRequestPermissionsResult(FlutterActivityDelegate.java:127)
E/AndroidRuntime( 6772): 	at io.flutter.app.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:137)
E/AndroidRuntime( 6772): 	at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7737)
E/AndroidRuntime( 6772): 	at android.app.Activity.dispatchActivityResult(Activity.java:7560)
E/AndroidRuntime( 6772): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4487)
E/AndroidRuntime( 6772): 	... 9 more

After crash I can launch Qrview normaly but, just crash one time at the permission choice.

More info : I use the plugin in an alertedialog
Thank you

iOS wrong dimension after orientation change

I used the example of the plugin for testing purposes.

https://github.com/juliuscanute/qr_code_scanner/blob/master/example/lib/main.dart

I have modified the main.dart file as follows:

...
children: <Widget>[
          Expanded(
            child: Center(
              child: SizedBox(
                width: 300.0,
                height: 200.0,
                child: QRView(
                  key: qrKey,
                  onQRViewCreated: _onQRViewCreated,
                ),
              ),
            ),
            flex: 4,
          ),
          Expanded(
...

After that I noticed that the camera preview is centered as desired with a width of 300.0 and a height of 200.0 when starting the app. If I rotate the device (iPad mini) from portrait to landscape or vice versa the camera preview becomes twice as big and overflows the SizedBox.

If in the file qr_code_scanner.dart on line 56 the width fix is set to 300.0 and the height fix is set to 200.0 everything works as desired!

Can't run project on Android devide

I have a problem during run or build apk in Class' QRView is not abstract and does not implement abstract member @UiThread public abstract fun onMethodCall (@nonnull p0: MethodCall, @nonnull p1 :Channel.Result Method): Unit defined in io. flutter.plugin.common.MethodChannel.MethodCallHandler

The position of overlay

I used the library and it worked great.

But it seems that the overlay is always in the center of screen.

How can I adjust the position of overlay?

[ASK] Is there a way to handle Android permissions?

I noticed that the QRView is handling the Android permission flow itself/internally and is prompting the user with the Android dialog asking for permission to access the device's camera.

Is there a way that I can get the result of this dialog? If the user rejects the permission, I can see an Android stacktrace in the console but have no way of catching the exception.

Cannot run project on ios device

Tried to run example from this project, but couldn't run, so I tried to create a new project with swift support to replicate the problem:

Steps to reproduce:

flutter create -i swift -a kotlin swift_qr_test

Copy the code from https://github.com/juliuscanute/qr_code_scanner/blob/master/example/lib/main.dart into the project main

flutter run on ios device (iPhone 6, iPad air and iPhone 5s tested)

Result:

=== BUILD TARGET qr_code_scanner OF PROJECT Pods WITH CONFIGURATION Debug ===
    /Users/goncalopalma/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.0.2/ios/Classes/FlutterQrPlugin.m:2:9:
    fatal error: 'qr_code_scanner-Swift.h' file not found
    #import "qr_code_scanner-Swift.h"
            ^~~~~~~~~~~~~~~~~~~~~~~~~

Not able to compare qrText with a String

Hello, I am very new to Flutter and I just wanted to compare the qrtext value with a String.

if(text == "-LrJtIuHApgNQmIIg9Xd")

But for some reason it doesn't work. If I print the value, I can see that it have to be the same, but the value is somehow set later.

thanks in advanced

thank you your plugin

Your plugin very nice,but I found when I exit the cameraPage but the console always print "E/Camera-JNI( 9959): copyAndPost: off=0, size=3110400 msg=10" , it really no Problem? Have any method to dispose the camera when I leave the page?

[android] ArithmeticException Crash

java.lang.ArithmeticException: divide by zero
E/AndroidRuntime(27427): 	at com.journeyapps.barcodescanner.CameraPreview.calculateFrames(CameraPreview.java:389)
E/AndroidRuntime(27427): 	at com.journeyapps.barcodescanner.CameraPreview.previewSized(CameraPreview.java:461)
E/AndroidRuntime(27427): 	at com.journeyapps.barcodescanner.CameraPreview.access$300(CameraPreview.java:59)
E/AndroidRuntime(27427): 	at com.journeyapps.barcodescanner.CameraPreview$3.handleMessage(CameraPreview.java:199)
E/AndroidRuntime(27427): 	at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime(27427): 	at android.os.Looper.loop(Looper.java:207)
E/AndroidRuntime(27427): 	at android.app.ActivityThread.main(ActivityThread.java:7539)
E/AndroidRuntime(27427): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27427): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/AndroidRuntime(27427): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

sometime occur.
due to upstream library
journeyapps/zxing-android-embedded#334
journeyapps/zxing-android-embedded#463

PlatformException(unregistered_view_type, trying to create a view with an unregistered type, unregistered view type: 'net.touchcapture.qr.flutterqr/qrview')

add io.flutter.embedded_views_preview

error

Unhandled Exception: PlatformException(unregistered_view_type, trying to create a view with an unregistered type, unregistered view type: 'net.touchcapture.qr.flutterqr/qrview')
#362    Element.updateChild 
package:flutter/…/widgets/framework.dart:2876
#363    SingleChildRenderObjectElement.update 
package:flutter/…/widgets/framework.dart:5099
#364    Element.updateChild 
package:flutter/…/widgets/framework.dart:2876
#365    ComponentElement.performRebuild 
package:flutter/…/widgets/framework.dart:3935
#366    Element.rebuild 
package:flutter/…/widgets/framework.dart:3721
#367    StatefulElement.update 
package:flutter/…/widgets/framework.dart:4085
#368    Element.updateChild 
package:flutter/…/widgets/framework.dart:2876
#369    SingleChildRenderObjectElement.update 
package:flutter/…/widgets/framework.dart:5099
#370    Element.updateChild 
package:flutter/…/widgets/framework.dart:2876
#371    SingleChildRenderObjectElement.update 
package:flutter/…/widgets/framework.dart:5099
#372    Element.updateChild 
package:flutter/…/widgets/framework.dart:2876
#373    ComponentElement.performRebuild 
package:flutter/…/widgets/framework.dart:3935
#374    Element.rebuild 
package:flutter/…/widgets/framework.dart:3721
#375    BuildOwner.buildScope 
package:flutter/…/widgets/framework.dart:2340
#376    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame 
package:flutter/…/widgets/binding.dart:700
#377    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersis<…>

Some suggestions

1.Sound prompt after scanning
2.Code scanning frame with lightning effect

[FEATURE] QR code scan from image file

https://github.com/rolends1986/qr_code_scanner/blob/master/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRPhotoDecoder.kt

https://github.com/rolends1986/qr_code_scanner/blob/master/lib/qr_code_decoder.dart

   companion object {
        @JvmStatic
        fun registerWith(registrar: Registrar) {
            registrar
                    .platformViewRegistry()
                    .registerViewFactory(
                            "net.touchcapture.qr.flutterqr/qrview", QRViewFactory(registrar))
            QRPhotoDecoder(registrar)
        }
    }
 Future scanFromGallery() async {
    try {
      qrController.pauseCamera();
      var resultList = await MultiImagePicker.pickImages(
        maxImages: 1,
        materialOptions: MaterialOptions(
          actionBarTitle: "选择图片",
          allViewTitle: "所有图片",
          actionBarColor: "#f0f2f7",
          actionBarTitleColor: "#474747",
          lightStatusBar: false,
          statusBarColor: '#f0f2f7',
          startInAllView: false,
          selectCircleStrokeColor: "#ffffff",
          selectionLimitReachedText: "图片选取数量已足够,请取消选择后,再次选取",
          textOnNothingSelected: "请选择图片",
          backButtonDrawable: "ic_arrow_back_black_24dp",
          okButtonDrawable: "ic_check_black_24dp",
        ),
      );
      if (resultList.length > 0) {
        setState(() {
          loading = true;
        });
        var path = await resultList.first.filePath;
        var qrResult = await QRDecoder(path).decode();
        if (!StringUtils.isNullOrEmpty(qrResult)) {
          QRCodeScanServices.internal().action(qrResult, context);
        } else {
          alert("选择的文件不包含二维码");
        }
        setState(() {
          loading = false;
        });
      }
    } on Exception catch (e) {
      if (e is NoImagesSelectedException) {
      } else {
        alert("无法选择相册(发生了错误)");
      }
    }finally{
      qrController.resumeCamera();
    }
  }

Only android implemented here...
It's just a suggestion.....

[iOS] App crushes without any Exit codes.

Works fine on android, But on ios, when the screen gets pushed, it will request camera permission (rather it is already granted) and app just crushes without any exit code when running via flutter.

when running via xcode, it will give error code

2019-09-14 04:38:44.027931+0900 Runner[1427:183336] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-09-14 04:38:44.030422+0900 Runner[1427:183336] [MC] Reading from public effective user settings.
(lldb) 

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

which is not very helpful..

Problem is It wont work with google maps.
The example app works, but when pushing that screen from google maps contained screen, app will crash

Stop repeatedly triggering onQRViewCreated

Hi,

First of all, thank you for the plugin. I have a few questions which I couldn't seem to find answers to, so I hope you can help shed some light on it.

  1. How do I stop the scanner from triggering onQRViewCreated callback method after the first scan is received? It seems like it's running in a while loop and the onQRViewCreated is constantly being called, even though I am not scanning.

  2. Is there a way to limit the amount of log messages? Right now it pretty much fill the whole screen in no time, and there's no way to stop it.

Thank you very much. Look forward to hearing from you.

Crash app after permissions

Hi

I have an error when the package requests the camera permissions in Android devices and the app close unexpectedly. Attach image with the error.

Captura de Pantalla 2019-11-06 a la(s) 8 09 31 p  m

Thanks

D8: Program type already present: com.google.zxing.BarcodeFormat

D8: Program type already present: com.google.zxing.ChecksumException

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    ...
    ...
    ...
    Program type already present: com.google.zxing.ChecksumException

Cannot run project on ios device

Hi please I am getting this error on Xcode
'qr_code_scanner-Swift.h' file not found
and I have not been able to resolve it, any lead on this thanks.

[ASK] QR Overlay design question

I need your help guys, I've now tried several different QR scanners for Flutter and none of them provide easy to customize overlays/heights, widths, etc.

I've realised the following app in React Native and have to rebuild it exactly like this in Flutter aswell:
Screen

Now my question: Is it possible to realise the same with this qr_code_scanner by @juliuscanute ? Everytime I try to put the scanner into a Stack widget it tells me theres an issue regarding flex and that the scanner can't have a parent widget that constrains its flex properties. But I need the Stack to be able to overlay the animated scanning line and the rounded corners.. Also I can't get it to add padding to the left and right sides because again, flex properties misbehaving..

Is this even possible?

Can't run project on iOS devide

Downloading dependencies
-> Installing Flutter (1.0.0)
-> Installing MTBBarcodeScanner (5.0.8)
> Copying MTBBarcodeScanner from /Users/pmcarlos/Library/Caches/CocoaPods/Pods/Release/MTBBarcodeScanner/5.0.8-5b97f to Pods/MTBBarcodeScanner
-> Installing qr_code_scanner (0.0.2)
-> Installing shared_preferences (0.0.1)
- Running pre install hooks
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod qr_code_scanner depends upon MTBBarcodeScanner, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:141:in verify_swift_pods_have_module_dependencies' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:38:in validate!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:459:in validate_targets' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:138:in install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in run' /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in run' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/bin/pod:55:in <top (required)>'
/usr/local/bin/pod:22:in load' /usr/local/bin/pod:22:in

'
Error output from CocoaPods:

[!] Automatically assigning platform ios with version 8.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

Hi I am having this problem,
I have added s.swift_version = '4.2' to the podpsec but it's not working

AndroidX Error: Trying to create an already created platform view

Whenever I run the example for the first time, It works perfectly fine. As soon as i hot restart, I get the error below: (This only happens on Android, and it only started happening when i added android x to the project)

E/flutter (24613): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create an already created platform view, view id: 0
E/flutter (24613): at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:85)
E/flutter (24613): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
E/flutter (24613): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/flutter (24613): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/flutter (24613): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/flutter (24613): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/flutter (24613): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (24613): at android.os.MessageQueue.next(MessageQueue.java:143)
E/flutter (24613): at android.os.Looper.loop(Looper.java:130)
E/flutter (24613): at android.app.ActivityThread.main(ActivityThread.java:6838)
E/flutter (24613): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (24613): at java.lang.reflect.Method.invoke(Method.java:372)
E/flutter (24613): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
E/flutter (24613): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
E/flutter (24613): , null)
E/flutter (24613): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (24613): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (24613):
E/flutter (24613): #2 AndroidViewController._create (package:flutter/src/services/platform_views.dart:640:54)
E/flutter (24613): #3 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:557:14)
E/flutter (24613): #4 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:174:29)
E/flutter (24613): #5 RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:155:5)
E/flutter (24613): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1703:9)
E/flutter (24613): #7 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (24613): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #9 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:505:15)
E/flutter (24613): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #11 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:806:17)
E/flutter (24613): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #13 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:505:15)
E/flutter (24613): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #15 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
E/flutter (24613): #16 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
E/flutter (24613): #17 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
E/flutter (24613): #18 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
E/flutter (24613): #19 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #20 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (24613): #21 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #22 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (24613): #23 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1232:11)
E/flutter (24613): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #25 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:505:15)
E/flutter (24613): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (24613): #27 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (24613): #28 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1584:7)
E/flutter (24613): #29 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
E/flutter (24613): #30 RendererBinding.drawFrame (package:flutter/src/r

Cant run project on ios device

[!] Unable to determine Swift version for the following pods:

qr_code_scanner does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/installer/xcode/target_validator.rb:122:in verify_swift_pods_swift_version' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/installer/xcode/target_validator.rb:37:in validate!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/installer.rb:578:in validate_targets' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/installer.rb:158:in install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/command/install.rb:51:in run' /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/lib/cocoapods/command.rb:52:in run' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.0.beta.3/bin/pod:55:in <top (required)>'
/usr/local/bin/pod:22:in load' /usr/local/bin/pod:22:in

'

[!] Automatically assigning platform ios with version 8.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

GC

Background sticky concurrent mark sweep GC freed 3073(270KB) AllocSpace objects, 5(5MB) LOS objects, 30% free, 14MB/20MB, paused 6.802ms total 17.953ms

Render QRView In Dialog

I tried to render QrView inside Dialog ... but it seems like its not rendering in the center of layout .. So i wanna know how to do it. Thanks

Screen Shot 2563-01-16 at 15 03 46

qrcode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.