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.
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.
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 21
}
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.
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>
The default camera is the back camera.
await controller.flipCamera();
By default, flash is OFF.
await controller.toggleFlash();
Pause camera stream and scanner.
await controller.pauseCamera();
Resume camera stream and scanner.
await controller.resumeCamera();
Requires at least SDK 21. Requires at least iOS 8.